diff --git a/src/main/java/com/noorq/casser/mapping/Column.java b/src/main/java/com/noorq/casser/mapping/Column.java index 614ffc4..510415b 100644 --- a/src/main/java/com/noorq/casser/mapping/Column.java +++ b/src/main/java/com/noorq/casser/mapping/Column.java @@ -31,7 +31,5 @@ public @interface Column { int ordinal() default 0; - boolean isStatic() default false; - boolean forceQuote() default false; } diff --git a/src/main/java/com/noorq/casser/mapping/ColumnInformation.java b/src/main/java/com/noorq/casser/mapping/ColumnInformation.java index 26f71d1..34e6298 100644 --- a/src/main/java/com/noorq/casser/mapping/ColumnInformation.java +++ b/src/main/java/com/noorq/casser/mapping/ColumnInformation.java @@ -53,14 +53,22 @@ public final class ColumnInformation { ordinalLocal = clusteringColumn.ordinal(); orderingLocal = clusteringColumn.ordering(); } - + + StaticColumn staticColumn = getter.getDeclaredAnnotation(StaticColumn.class); + if (staticColumn != null) { + ensureSingleColumnType(columnTypeLocal, getter); + columnName = staticColumn.value(); + forceQuote = staticColumn.forceQuote(); + columnTypeLocal = ColumnType.STATIC_COLUMN; + ordinalLocal = staticColumn.ordinal(); + } Column column = getter.getDeclaredAnnotation(Column.class); if (column != null) { ensureSingleColumnType(columnTypeLocal, getter); columnName = column.value(); forceQuote = column.forceQuote(); - columnTypeLocal = column.isStatic() ? ColumnType.STATIC_COLUMN : ColumnType.COLUMN; + columnTypeLocal = ColumnType.COLUMN; ordinalLocal = column.ordinal(); } diff --git a/src/main/java/com/noorq/casser/mapping/StaticColumn.java b/src/main/java/com/noorq/casser/mapping/StaticColumn.java new file mode 100644 index 0000000..6e478b1 --- /dev/null +++ b/src/main/java/com/noorq/casser/mapping/StaticColumn.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 Noorq, Inc. + * + * 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.noorq.casser.mapping; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.METHOD, ElementType.ANNOTATION_TYPE }) +public @interface StaticColumn { + + String value() default ""; + + int ordinal() default 0; + + boolean forceQuote() default false; + +}