summaryrefslogtreecommitdiff
path: root/src/test/java/com/amazon/carbonado/stored
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/amazon/carbonado/stored')
-rw-r--r--src/test/java/com/amazon/carbonado/stored/UserAddress.java2
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerived.java69
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerived2.java48
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedChainA.java53
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedChainB.java45
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedChainC.java45
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedChainD.java38
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedCycle.java37
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedCycle2.java47
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedDoubleObjVersion.java45
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedFloatVersion.java44
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedStringVersion.java45
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithDerivedVersion.java44
-rw-r--r--src/test/java/com/amazon/carbonado/stored/WithFunctionIndex.java50
14 files changed, 611 insertions, 1 deletions
diff --git a/src/test/java/com/amazon/carbonado/stored/UserAddress.java b/src/test/java/com/amazon/carbonado/stored/UserAddress.java
index 466f6eb..bee9683 100644
--- a/src/test/java/com/amazon/carbonado/stored/UserAddress.java
+++ b/src/test/java/com/amazon/carbonado/stored/UserAddress.java
@@ -62,5 +62,5 @@ public abstract class UserAddress implements Storable<UserAddress> {
@Nullable
@Join(internal="neighborAddressID", external="addressID")
public abstract UserAddress getNeighbor() throws FetchException;
- public abstract void setNeighbor(UserAddress address) throws FetchException;
+ public abstract void setNeighbor(UserAddress address);
}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerived.java b/src/test/java/com/amazon/carbonado/stored/WithDerived.java
new file mode 100644
index 0000000..d5cc69a
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerived.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+public abstract class WithDerived implements Storable {
+ public abstract int getID();
+ public abstract void setID(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ @Derived(from="name")
+ public String getUpperCaseName() {
+ String name = getName();
+ if (name != null) {
+ name = name.toUpperCase();
+ }
+ return name;
+ }
+
+ @Derived(from={"ID", "name"})
+ public String getIDAndName() {
+ return String.valueOf(getID()) + ':' + getName();
+ }
+
+ @Derived(from={"ID", "upperCaseName"})
+ public String getIDAndUpperCaseName() {
+ return String.valueOf(getID()) + ':' + getUpperCaseName();
+ }
+
+ @Derived(from={"IDAndUpperCaseName"})
+ public String getLongKey() {
+ return getIDAndUpperCaseName();
+ }
+
+ @Derived(from={"longKey", "ID", "name", "upperCaseName", "IDAndUpperCaseName"})
+ public String getAnotherLongKey() {
+ return getLongKey();
+ }
+
+ @Derived
+ public String getYetAnotherLongKey() {
+ return getAnotherLongKey();
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerived2.java b/src/test/java/com/amazon/carbonado/stored/WithDerived2.java
new file mode 100644
index 0000000..1ece0a2
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerived2.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("key")
+public abstract class WithDerived2 implements Storable {
+ public abstract int getKey();
+ public abstract void setKey(int id);
+
+ public abstract int getId();
+ public abstract void setId(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ @Join
+ public abstract StorableTestBasic getBasic() throws FetchException;
+ public abstract void setBasic(StorableTestBasic basic);
+
+ // This is an error because "basic" isn't doubly joined.
+ @Derived(from="basic.intProp")
+ public int getIntProp() throws FetchException, Exception {
+ return getBasic().getIntProp();
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedChainA.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedChainA.java
new file mode 100644
index 0000000..77d82ef
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedChainA.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("aid")
+@Indexes(@Index("DName"))
+public abstract class WithDerivedChainA implements Storable {
+ public abstract int getAid();
+ public abstract void setAid(int id);
+
+ public abstract int getBid();
+ public abstract void setBid(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ @Join
+ public abstract WithDerivedChainB getB() throws FetchException;
+ public abstract void setB(WithDerivedChainB b);
+
+ @Derived(from="b.c.d.name")
+ public String getDName() throws FetchException {
+ return getB().getC().getD().getName();
+ }
+
+ @Derived(from="DName")
+ public String getUpperDName() throws FetchException {
+ return getDName().toUpperCase();
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedChainB.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedChainB.java
new file mode 100644
index 0000000..85c8de3
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedChainB.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("bid")
+public abstract class WithDerivedChainB implements Storable {
+ public abstract int getBid();
+ public abstract void setBid(int id);
+
+ public abstract int getCid();
+ public abstract void setCid(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ @Join
+ public abstract WithDerivedChainC getC() throws FetchException;
+ public abstract void setC(WithDerivedChainC c);
+
+ @Join
+ public abstract Query<WithDerivedChainA> getAQuery() throws FetchException;
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedChainC.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedChainC.java
new file mode 100644
index 0000000..ea1713e
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedChainC.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("cid")
+public abstract class WithDerivedChainC implements Storable {
+ public abstract int getCid();
+ public abstract void setCid(int id);
+
+ public abstract int getDid();
+ public abstract void setDid(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ @Join
+ public abstract WithDerivedChainD getD() throws FetchException;
+ public abstract void setD(WithDerivedChainD d);
+
+ @Join
+ public abstract Query<WithDerivedChainB> getBQuery() throws FetchException;
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedChainD.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedChainD.java
new file mode 100644
index 0000000..5d10480
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedChainD.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("did")
+public abstract class WithDerivedChainD implements Storable {
+ public abstract int getDid();
+ public abstract void setDid(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ @Join
+ public abstract Query<WithDerivedChainC> getCQuery() throws FetchException;
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedCycle.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedCycle.java
new file mode 100644
index 0000000..022375d
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedCycle.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+public abstract class WithDerivedCycle implements Storable {
+ public abstract int getID();
+ public abstract void setID(int id);
+
+ @Derived(from="selfCycle")
+ public String getSelfCycle() {
+ return null;
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedCycle2.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedCycle2.java
new file mode 100644
index 0000000..fb09989
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedCycle2.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+public abstract class WithDerivedCycle2 implements Storable {
+ public abstract int getID();
+ public abstract void setID(int id);
+
+ @Derived(from="b")
+ public String getA() {
+ return getB();
+ }
+
+ @Derived(from="c")
+ public String getB() {
+ return getC();
+ }
+
+ @Derived(from="a")
+ public String getC() {
+ return getA();
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedDoubleObjVersion.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedDoubleObjVersion.java
new file mode 100644
index 0000000..d4efb1e
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedDoubleObjVersion.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+public abstract class WithDerivedDoubleObjVersion implements Storable {
+ public abstract int getID();
+ public abstract void setID(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ @Nullable
+ public abstract Double getValue();
+ public abstract void setValue(Double value);
+
+ @Derived
+ @Version
+ public Double getVersion() {
+ return getValue();
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedFloatVersion.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedFloatVersion.java
new file mode 100644
index 0000000..df3c135
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedFloatVersion.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+public abstract class WithDerivedFloatVersion implements Storable {
+ public abstract int getID();
+ public abstract void setID(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ public abstract float getValue();
+ public abstract void setValue(float value);
+
+ @Derived
+ @Version
+ public float getVersion() {
+ return getValue();
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedStringVersion.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedStringVersion.java
new file mode 100644
index 0000000..73ab504
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedStringVersion.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+public abstract class WithDerivedStringVersion implements Storable {
+ public abstract int getID();
+ public abstract void setID(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ @Nullable
+ public abstract String getValue();
+ public abstract void setValue(String value);
+
+ @Derived
+ @Version
+ public String getVersion() {
+ return getValue();
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithDerivedVersion.java b/src/test/java/com/amazon/carbonado/stored/WithDerivedVersion.java
new file mode 100644
index 0000000..9c0d15a
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithDerivedVersion.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+public abstract class WithDerivedVersion implements Storable {
+ public abstract int getID();
+ public abstract void setID(int id);
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ public abstract int getValue();
+ public abstract void setValue(int value);
+
+ @Derived
+ @Version
+ public int getVersion() {
+ return getValue();
+ }
+}
diff --git a/src/test/java/com/amazon/carbonado/stored/WithFunctionIndex.java b/src/test/java/com/amazon/carbonado/stored/WithFunctionIndex.java
new file mode 100644
index 0000000..ad5c5db
--- /dev/null
+++ b/src/test/java/com/amazon/carbonado/stored/WithFunctionIndex.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. 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.amazon.carbonado.stored;
+
+import com.amazon.carbonado.*;
+
+/**
+ *
+ *
+ * @author Brian S O'Neill
+ */
+@PrimaryKey("ID")
+@Indexes({@Index("average"), @Index("averageObject")})
+public abstract class WithFunctionIndex implements Storable {
+ public abstract int getID();
+ public abstract void setID(int id);
+
+ public abstract int getSum();
+ public abstract void setSum(int sum);
+
+ public abstract int getCount();
+ public abstract void setCount(int count);
+
+ @Derived
+ public double getAverage() {
+ return ((double) getSum()) / getCount();
+ }
+
+ @Derived
+ @Nullable
+ public Double getAverageObject() {
+ return ((double) getSum()) / getCount();
+ }
+}