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

com.github.helenusdriver.persistence.Column 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.persistence;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import java.math.BigDecimal;
import java.math.BigInteger;

import java.net.InetAddress;

import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;

import java.nio.ByteBuffer;
import java.time.Instant;
import java.time.ZoneId;

import com.github.helenusdriver.annotation.Keyable;

/**
 * The Column annotation specifies a mapped column for a persistent
 * property or field.
 *
 * @copyright 2015-2015 The Helenus Driver Project Authors
 *
 * @author  The Helenus Driver Project Authors
 * @version 1 - Jan 15, 2015 - paouelle - Creation
 *
 * @since 1.0
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Columns.class)
@Keyable("table")
@Documented
public @interface Column {
  /**
   * The name of the table as defined in {@link Table#name} this column is
   * associated with.
   * 

* By default, if none specified, the column will be persisted in all tables * defined by the entity. * * @author paouelle * * @return the name of the table this column is associated with */ String table() default Table.ALL; /** * The name of the column. * * @author paouelle * * @return the name of the column */ String name(); /** * The Data annotation is used to override the default mapping of * data types from the field's class of a column with a specified one. This * annotation applies to all tables the column might be persisted to. * * @copyright 2015-2015 The Helenus Driver Project Authors * * @author The Helenus Driver Project Authors * @version 1 - Jan 15, 2015 - paouelle - Creation * * @since 1.0 */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Data { /** * The optional CQL data type. If not provided, the data type is inferred * from the corresponding attribute type: * - "ascii" - {@link Enum}, {@link Class}, {@link Locale}, or {@link ZoneId} * - "bigint" - {@link Long} * - "blob" - byte[] or {@link ByteBuffer} * - "boolean" - {@link Boolean} * - "counter" - {@link AtomicLong} * - "decimal" - {@link BigDecimal} * - "double" - {@link Double} * - "float" - {@link Float} * - "inet" - {@link InetAddress} * - "int" - {@link Integer} * - "text" - {@link String} * - "timestamp" - {@link Date} or {@link Instant} * - "uuid" - {@link UUID} * - "varint" - {@link BigInteger} * * - "list<ctype>" - {@link List} of the corresponding element type * - "map<ctype, ctype>" - {@link Map} of the corresponding element types * - "set<ctype>" - {@link Set} of the corresponding element type * * @author paouelle * * @return the optional CQL data type */ DataType type() default DataType.INFERRED; /** * Optionally indicates the argument types for a collection type. Only used * when {@link DataType#LIST}, {@link DataType#SET}, or {@link DataType#MAP} * is defined as {@link #type} and cannot be set to one of the collection * type either. * * @author paouelle * * @return the optional argument types for a collection type */ DataType[] arguments() default {}; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy