Package org.apache.gora.examples.generated

Source Code of org.apache.gora.examples.generated.Metadata

/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.gora.examples.generated;

import java.nio.ByteBuffer;
import java.util.Map;
import java.util.HashMap;
import org.apache.avro.Protocol;
import org.apache.avro.Schema;
import org.apache.avro.AvroRuntimeException;
import org.apache.avro.Protocol;
import org.apache.avro.util.Utf8;
import org.apache.avro.ipc.AvroRemoteException;
import org.apache.avro.generic.GenericArray;
import org.apache.avro.specific.SpecificExceptionBase;
import org.apache.avro.specific.SpecificRecordBase;
import org.apache.avro.specific.SpecificRecord;
import org.apache.avro.specific.SpecificFixed;
import org.apache.gora.persistency.StateManager;
import org.apache.gora.persistency.impl.PersistentBase;
import org.apache.gora.persistency.impl.StateManagerImpl;
import org.apache.gora.persistency.StatefulHashMap;
import org.apache.gora.persistency.ListGenericArray;

@SuppressWarnings("all")
public class Metadata extends PersistentBase {
  public static final Schema _SCHEMA = Schema.parse("{\"type\":\"record\",\"name\":\"Metadata\",\"namespace\":\"org.apache.gora.examples.generated\",\"fields\":[{\"name\":\"version\",\"type\":\"int\"},{\"name\":\"data\",\"type\":{\"type\":\"map\",\"values\":\"string\"}}]}");
  public static enum Field {
    VERSION(0,"version"),
    DATA(1,"data"),
    ;
    private int index;
    private String name;
    Field(int index, String name) {this.index=index;this.name=name;}
    public int getIndex() {return index;}
    public String getName() {return name;}
    public String toString() {return name;}
  };
  public static final String[] _ALL_FIELDS = {"version","data",};
  static {
    PersistentBase.registerFields(Metadata.class, _ALL_FIELDS);
  }
  private int version;
  private Map<Utf8,Utf8> data;
  public Metadata() {
    this(new StateManagerImpl());
  }
  public Metadata(StateManager stateManager) {
    super(stateManager);
    data = new StatefulHashMap<Utf8,Utf8>();
  }
  public Metadata newInstance(StateManager stateManager) {
    return new Metadata(stateManager);
  }
  public Schema getSchema() { return _SCHEMA; }
  public Object get(int _field) {
    switch (_field) {
    case 0: return version;
    case 1: return data;
    default: throw new AvroRuntimeException("Bad index");
    }
  }
  @SuppressWarnings(value="unchecked")
  public void put(int _field, Object _value) {
    if(isFieldEqual(_field, _value)) return;
    getStateManager().setDirty(this, _field);
    switch (_field) {
    case 0:version = (Integer)_value; break;
    case 1:data = (Map<Utf8,Utf8>)_value; break;
    default: throw new AvroRuntimeException("Bad index");
    }
  }
  public int getVersion() {
    return (Integer) get(0);
  }
  public void setVersion(int value) {
    put(0, value);
  }
  public Map<Utf8, Utf8> getData() {
    return (Map<Utf8, Utf8>) get(1);
  }
  public Utf8 getFromData(Utf8 key) {
    if (data == null) { return null; }
    return data.get(key);
  }
  public void putToData(Utf8 key, Utf8 value) {
    getStateManager().setDirty(this, 1);
    data.put(key, value);
  }
  public Utf8 removeFromData(Utf8 key) {
    if (data == null) { return null; }
    getStateManager().setDirty(this, 1);
    return data.remove(key);
  }
}
TOP

Related Classes of org.apache.gora.examples.generated.Metadata

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.