All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.camel.component.hbase.model.HBaseCell Maven / Gradle / Ivy

There is a newer version: 3.22.2
Show newest version
/*
 * 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.camel.component.hbase.model;

/**
 * A simplified representation of HBase KeyValue objects, which uses the actual Objects instead of byte arrays. It is
 * used in order to abstract the conversion strategy from CellMappingStrategy. It is also used as a template to specify
 * which will be the columns returned in gets, scans etc.
 */
public class HBaseCell {

    private String family;
    private String qualifier;
    private Object value;
    private Long timestamp;
    //The value type can be optionally specified for Gets and Scan, to specify how the byte[] read will be converted.
    private Class valueType = String.class;

    @Override
    public String toString() {
        return "HBaseCell=[family=" + family + ", qualifier=" + qualifier + ", value=" + value + ", valueType="
               + valueType.getName();
    }

    public String getFamily() {
        return family;
    }

    public void setFamily(String family) {
        this.family = family;
    }

    public String getQualifier() {
        return qualifier;
    }

    public void setQualifier(String qualifier) {
        this.qualifier = qualifier;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public Class getValueType() {
        return valueType;
    }

    public void setValueType(Class valueType) {
        if (valueType == null) {
            throw new IllegalArgumentException("Value type can not be null");
        }
        this.valueType = valueType;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        HBaseCell hBaseCell = (HBaseCell) o;

        if (family != null ? !family.equals(hBaseCell.family) : hBaseCell.family != null) {
            return false;
        }
        if (qualifier != null ? !qualifier.equals(hBaseCell.qualifier) : hBaseCell.qualifier != null) {
            return false;
        }
        if (timestamp != null ? !timestamp.equals(hBaseCell.timestamp) : hBaseCell.timestamp != null) {
            return false;
        }
        if (value != null ? !value.equals(hBaseCell.value) : hBaseCell.value != null) {
            return false;
        }
        if (valueType != null ? !valueType.equals(hBaseCell.valueType) : hBaseCell.valueType != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = family != null ? family.hashCode() : 0;
        result = 31 * result + (qualifier != null ? qualifier.hashCode() : 0);
        result = 31 * result + (value != null ? value.hashCode() : 0);
        result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0);
        result = 31 * result + (valueType != null ? valueType.hashCode() : 0);
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy