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

com.github.helenusdriver.driver.info.FieldInfo Maven / Gradle / Ivy

Go to download

JPA-like syntax for annotating POJO classes for persistence via Cassandra's Java driver - API

The newest version!
/*
 * Copyright (C) 2015-2015 The Helenus Driver Project Authors.
 *
 * 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.github.helenusdriver.driver.info;

import java.lang.annotation.Annotation;

import com.github.helenusdriver.persistence.ClusteringKey;
import com.github.helenusdriver.persistence.Index;
import com.github.helenusdriver.persistence.PartitionKey;
import com.github.helenusdriver.persistence.Persisted;
import com.github.helenusdriver.persistence.SuffixKey;
import com.github.helenusdriver.persistence.TypeKey;




/**
 * The FieldInfo interface provides information about a specific
 * field in a given table for a particular POJO class.
 *
 * @copyright 2015-2015 The Helenus Driver Project Authors
 *
 * @author  The Helenus Driver Project Authors
 * @version 1 - Jan 15, 2015 - paouelle - Creation
 *
 * @param  The type of POJO represented by this class
 *
 * @since 2.0
 */
public interface FieldInfo {
  /**
   * Gets the class of POJO represented by this class info object.
   *
   * @author paouelle
   *
   * @return the non-null type of POJO represented by this class
   *         info
   */
  public Class getObjectClass();

  /**
   * Gets the class declaring this field.
   *
   * @author paouelle
   *
   * @return the non-null class declaring this field
   */
  public Class getDeclaringClass();

  /**
   * Gets the class info for the POJO.
   *
   * @author paouelle
   *
   * @return the non-null class info for the POJO
   */
  public ClassInfo getClassInfo();

  /**
   * Gets the table info this field is defined in.
   *
   * @author paouelle
   *
   * @return the table info this field is defined in or null
   *         if it represents only a suffix and not a column
   */
  public TableInfo getTableInfo();

  /**
   * Gets the field name.
   *
   * @author paouelle
   *
   * @return the non-null field name
   */
  public String getName();

  /**
   * Gets the type for this field.
   *
   * @author paouelle
   *
   * @return the non-null type for this field
   */
  public Class getType();

  /**
   * Checks if the field is annotated as a column.
   *
   * @author paouelle
   *
   * @return true if the field is annotated as a column;
   *         false otherwise
   */
  public boolean isColumn();

  /**
   * Checks if this field is annotated has a suffix key.
   *
   * @author paouelle
   *
   * @return true if this field is annotated as a suffix key;
   *         false otherwise
   */
  public boolean isSuffixKey();

  /**
   * Gets the column name for this field.
   *
   * @author paouelle
   *
   * @return the column name for this field if it is annotated as a column;
   *         null otherwise
   */
  public String getColumnName();

  /**
   * Gets the suffix key name for this field.
   *
   * @author paouelle
   *
   * @return the suffix key name for this field if it is annotated as a suffix
   *         key; null otherwise
   */
  public String getSuffixKeyName();

  /**
   * Gets the suffix key annotation for this field.
   *
   * @author paouelle
   *
   * @return the suffix key annotation for this field if it is annotated as a
   *         suffix key; null otherwise
   */
  public SuffixKey getSuffixKey();

  /**
   * Checks if this field is mandatory.
   *
   * @author paouelle
   *
   * @return true if this field is mandatory and cannot be
   *         null; false otherwise
   */
  public boolean isMandatory();

  /**
   * Checks if this field is an index.
   *
   * @author paouelle
   *
   * @return true if this field is an index; false
   *         otherwise
   */
  public boolean isIndex();

  /**
   * Gets the index annotation for this field.
   *
   * @author paouelle
   *
   * @return the index annotation for this field if this field is an index;
   *         null otherwise
   */
  public Index getIndex();

  /**
   * Checks if this field is a counter.
   *
   * @author paouelle
   *
   * @return true if this field is a counter; false
   *         otherwise
   */
  public boolean isCounter();

  /**
   * Checks if this column is the last key in the partition or the cluster if
   * this field represents a primary key.
   *
   * @author paouelle
   *
   * @return true if this key is the last in the partition or the
   *         cluster; false otherwise
   */
  public boolean isLast();

  /**
   * Checks if this field is also a partition key.
   *
   * @author paouelle
   *
   * @return true if this field is a partition key; false
   *         otherwise
   */
  public boolean isPartitionKey();

  /**
   * Gets the partition key annotation for this field.
   *
   * @author paouelle
   *
   * @return the partition key annotation for this field if it is defined as
   *         a partition key; null otherwise
   */
  public PartitionKey getPartitionKey();

  /**
   * Checks if this field is also a clustering key.
   *
   * @author paouelle
   *
   * @return true if this field is a clustering key; false
   *         otherwise
   */
  public boolean isClusteringKey();

  /**
   * Gets the clustering key annotation for this field.
   *
   * @author paouelle
   *
   * @return the clustering key annotation for this field if it is defined as
   *         a clustering key; null otherwise
   */
  public ClusteringKey getClusteringKey();

  /**
   * Checks if this field is also a type key.
   *
   * @author paouelle
   *
   * @return true if this field is a type key; false
   *         otherwise
   */
  public boolean isTypeKey();

  /**
   * Gets the type key annotation for this field.
   *
   * @author paouelle
   *
   * @return the type key annotation for this field if it is defined as
   *         a type key; null otherwise
   */
  public TypeKey getTypeKey();

  /**
   * Checks if this field is a multi-key.
   *
   * @author paouelle
   *
   * @return true if the field is a multi-key;
   *         false otherwise
   */
  public boolean isMultiKey();

  /**
   * Checks if this field is persisted (i.e. annotated with {@link Persisted}).
   *
   * @author paouelle
   *
   * @return true if this field is persisted; false
   *         otherwise
   */
  public boolean isPersisted();

  /**
   * Gets this field's annotation for the specified type if such an annotation
   * is present.
   *
   * @param  the type of annotation to retrieve
   *
   * @param  annotationClass the Class object corresponding to the
   *         annotation type
   * @return this element's annotation for the specified annotation type if
   *         present on this element; otherwise null
   * @throws NullPointerException if the given annotation class is null
   */
  public  A getAnnotation(Class annotationClass);

  /**
   * Checks if the field is defined as final.
   *
   * @author paouelle
   *
   * @return true if the field is defined as final; false
   *         otherwise
   */
  public boolean isFinal();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy