com.asakusafw.compiler.bulkloader.testing.model.MockTableModel.java Source code

Java tutorial

Introduction

Here is the source code for com.asakusafw.compiler.bulkloader.testing.model.MockTableModel.java

Source

/**
 * Copyright 2011-2016 Asakusa Framework Team.
 *
 * Licensed 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 com.asakusafw.compiler.bulkloader.testing.model;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.Writable;

import com.asakusafw.compiler.bulkloader.testing.io.MockTableModelInput;
import com.asakusafw.compiler.bulkloader.testing.io.MockTableModelOutput;
import com.asakusafw.runtime.model.DataModel;
import com.asakusafw.runtime.model.DataModelKind;
import com.asakusafw.runtime.model.ModelInputLocation;
import com.asakusafw.runtime.model.ModelOutputLocation;
import com.asakusafw.runtime.model.PropertyOrder;
import com.asakusafw.runtime.value.IntOption;
import com.asakusafw.vocabulary.bulkloader.ColumnOrder;
import com.asakusafw.vocabulary.bulkloader.OriginalName;
import com.asakusafw.vocabulary.bulkloader.PrimaryKey;

/**
 * mock_table_model?
 */
@ColumnOrder(value = { "A", "B", "C" })
@DataModelKind("DMDL")
@ModelInputLocation(MockTableModelInput.class)
@ModelOutputLocation(MockTableModelOutput.class)
@OriginalName(value = "MOCK")
@PrimaryKey(value = { "a" })
@PropertyOrder({ "a", "b", "c" })
public class MockTableModel implements DataModel<MockTableModel>, Writable {
    private final IntOption a = new IntOption();
    private final IntOption b = new IntOption();
    private final IntOption c = new IntOption();

    @Override
    @SuppressWarnings("deprecation")
    public void reset() {
        this.a.setNull();
        this.b.setNull();
        this.c.setNull();
    }

    @Override
    @SuppressWarnings("deprecation")
    public void copyFrom(MockTableModel other) {
        this.a.copyFrom(other.a);
        this.b.copyFrom(other.b);
        this.c.copyFrom(other.c);
    }

    /**
     * a?
     * @return a
     * @throws NullPointerException a??<code>null</code>???
     */
    public int getA() {
        return this.a.get();
    }

    /**
     * a?
     * @param value ?
     */
    @SuppressWarnings("deprecation")
    public void setA(int value) {
        this.a.modify(value);
    }

    /**
     * <code>null</code>?a?
     * @return a
     */
    @OriginalName(value = "A")
    public IntOption getAOption() {
        return this.a;
    }

    /**
     * a?
     * @param option ??<code>null</code>???????<code>null</code>????
     */
    @SuppressWarnings("deprecation")
    public void setAOption(IntOption option) {
        this.a.copyFrom(option);
    }

    /**
     * b?
     * @return b
     * @throws NullPointerException b??<code>null</code>???
     */
    public int getB() {
        return this.b.get();
    }

    /**
     * b?
     * @param value ?
     */
    @SuppressWarnings("deprecation")
    public void setB(int value) {
        this.b.modify(value);
    }

    /**
     * <code>null</code>?b?
     * @return b
     */
    @OriginalName(value = "B")
    public IntOption getBOption() {
        return this.b;
    }

    /**
     * b?
     * @param option ??<code>null</code>???????<code>null</code>????
     */
    @SuppressWarnings("deprecation")
    public void setBOption(IntOption option) {
        this.b.copyFrom(option);
    }

    /**
     * c?
     * @return c
     * @throws NullPointerException c??<code>null</code>???
     */
    public int getC() {
        return this.c.get();
    }

    /**
     * c?
     * @param value ?
     */
    @SuppressWarnings("deprecation")
    public void setC(int value) {
        this.c.modify(value);
    }

    /**
     * <code>null</code>?c?
     * @return c
     */
    @OriginalName(value = "C")
    public IntOption getCOption() {
        return this.c;
    }

    /**
     * c?
     * @param option ??<code>null</code>???????<code>null</code>????
     */
    @SuppressWarnings("deprecation")
    public void setCOption(IntOption option) {
        this.c.copyFrom(option);
    }

    @Override
    public String toString() {
        StringBuilder result = new StringBuilder();
        result.append("{");
        result.append("class=mock_table_model");
        result.append(", a=");
        result.append(this.a);
        result.append(", b=");
        result.append(this.b);
        result.append(", c=");
        result.append(this.c);
        result.append("}");
        return result.toString();
    }

    @Override
    public int hashCode() {
        int prime = 31;
        int result = 1;
        result = prime * result + a.hashCode();
        result = prime * result + b.hashCode();
        result = prime * result + c.hashCode();
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        MockTableModel other = (MockTableModel) obj;
        if (this.a.equals(other.a) == false) {
            return false;
        }
        if (this.b.equals(other.b) == false) {
            return false;
        }
        if (this.c.equals(other.c) == false) {
            return false;
        }
        return true;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        a.write(out);
        b.write(out);
        c.write(out);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        a.readFields(in);
        b.readFields(in);
        c.readFields(in);
    }
}