Java tutorial
/** * Copyright (c) 2014 Baidu, Inc. All Rights Reserved. * * 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.baidu.rigel.biplatform.ma.model.meta; import java.io.Serializable; import java.util.List; import java.util.Set; import org.apache.commons.collections.CollectionUtils; import com.baidu.rigel.biplatform.ma.model.utils.GsonUtils; import com.google.common.collect.Sets; /** * * ?????? ?? * * * @author david.wang * */ public abstract class DimTableMetaDefine implements Serializable { /** * ?id */ private static final long serialVersionUID = -5151316866400344913L; /** * ????? * ? */ private Set<ColumnMetaDefine> columns; /** * ??????? */ private String name; /** * */ private ReferenceDefine reference; /** * */ public DimTableMetaDefine() { } /** * ? * * @return */ public ColumnMetaDefine[] getColumns() { if (columns == null) { columns = Sets.newLinkedHashSet(); } return columns.toArray(new ColumnMetaDefine[0]); } /** * * * @param column * ? */ public void addColumn(ColumnMetaDefine column) { if (columns == null) { columns = Sets.newLinkedHashSet(); } columns.add(column); } /** * ? * * @param columns * ? */ public void addColumns(List<ColumnMetaDefine> columns) { if (columns == null || columns.isEmpty()) { return; } if (this.columns == null) { this.columns = Sets.newLinkedHashSet(); } this.columns.addAll(columns); } /** * * @return ?? */ public String getName() { return name; } /** * ??????? * * @param name * ?? */ public void setName(String name) { this.name = name; } /** * * @return ?? */ public ReferenceDefine getReference() { return reference; } /** * ? * * @param reference * ?? */ public void setReference(ReferenceDefine reference) { this.reference = reference; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((columns == null) ? 0 : columns.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((reference == null) ? 0 : reference.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } DimTableMetaDefine other = (DimTableMetaDefine) obj; if (columns == null) { if (other.columns != null) { return false; } } else if (!CollectionUtils.isEqualCollection(columns, other.columns)) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } if (reference == null) { if (other.reference != null) { return false; } } else if (!reference.equals(other.reference)) { return false; } return true; } /** * {@inheritDoc} */ @Override public String toString() { return GsonUtils.toJson(this); } /** * * ?? * * @return ? extends DimType * @see DimType */ public abstract <T extends DimType> T getDimType(); }