add annotation StaticColumn

This commit is contained in:
Albert Shift 2015-04-14 09:49:05 -07:00
parent 88bacf02e0
commit 73733fdb06
3 changed files with 43 additions and 4 deletions

View file

@ -31,7 +31,5 @@ public @interface Column {
int ordinal() default 0;
boolean isStatic() default false;
boolean forceQuote() default false;
}

View file

@ -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();
}

View file

@ -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;
}