id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
134,700 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityIntrospector.java | EntityIntrospector.applyPropertyOverride | private void applyPropertyOverride(PropertyMetadata propertyMetadata) {
String name = propertyMetadata.getName();
Property override = entityMetadata.getPropertyOverride(name);
if (override != null) {
String mappedName = override.name();
if (mappedName != null && mappedName.trim().length() > 0) {
propertyMetadata.setMappedName(mappedName);
}
propertyMetadata.setIndexed(override.indexed());
propertyMetadata.setOptional(override.optional());
}
} | java | private void applyPropertyOverride(PropertyMetadata propertyMetadata) {
String name = propertyMetadata.getName();
Property override = entityMetadata.getPropertyOverride(name);
if (override != null) {
String mappedName = override.name();
if (mappedName != null && mappedName.trim().length() > 0) {
propertyMetadata.setMappedName(mappedName);
}
propertyMetadata.setIndexed(override.indexed());
propertyMetadata.setOptional(override.optional());
}
} | [
"private",
"void",
"applyPropertyOverride",
"(",
"PropertyMetadata",
"propertyMetadata",
")",
"{",
"String",
"name",
"=",
"propertyMetadata",
".",
"getName",
"(",
")",
";",
"Property",
"override",
"=",
"entityMetadata",
".",
"getPropertyOverride",
"(",
"name",
")",
... | Applies any override information for the property with the given metadata.
@param propertyMetadata
the metadata of the property | [
"Applies",
"any",
"override",
"information",
"for",
"the",
"property",
"with",
"the",
"given",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityIntrospector.java#L386-L398 |
134,701 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityIntrospector.java | EntityIntrospector.processEmbeddedField | private void processEmbeddedField(Field field) {
// First create EmbeddedField so we can maintain the path/depth of the
// embedded field
EmbeddedField embeddedField = new EmbeddedField(field);
// Introspect the embedded field.
EmbeddedMetadata embeddedMetadata = EmbeddedIntrospector.introspect(embeddedField,
entityMetadata);
entityMetadata.putEmbeddedMetadata(embeddedMetadata);
} | java | private void processEmbeddedField(Field field) {
// First create EmbeddedField so we can maintain the path/depth of the
// embedded field
EmbeddedField embeddedField = new EmbeddedField(field);
// Introspect the embedded field.
EmbeddedMetadata embeddedMetadata = EmbeddedIntrospector.introspect(embeddedField,
entityMetadata);
entityMetadata.putEmbeddedMetadata(embeddedMetadata);
} | [
"private",
"void",
"processEmbeddedField",
"(",
"Field",
"field",
")",
"{",
"// First create EmbeddedField so we can maintain the path/depth of the",
"// embedded field",
"EmbeddedField",
"embeddedField",
"=",
"new",
"EmbeddedField",
"(",
"field",
")",
";",
"// Introspect the e... | Processes and gathers the metadata for the given embedded field.
@param field
the embedded field | [
"Processes",
"and",
"gathers",
"the",
"metadata",
"for",
"the",
"given",
"embedded",
"field",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityIntrospector.java#L406-L414 |
134,702 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IdClassMetadata.java | IdClassMetadata.findIdReadMethod | private MethodHandle findIdReadMethod() {
try {
Method readMethod = clazz.getMethod(READ_METHOD_NAME);
Class<?> dataClass = readMethod.getReturnType();
DataType dataType = IdentifierMetadata.DataType.forClass(dataClass);
if (dataType == null) {
String pattern = "Method %s in class %s must have a return type of long, Long or String";
String error = String.format(pattern, READ_METHOD_NAME, clazz.getName());
throw new EntityManagerException(error);
}
return MethodHandles.lookup().unreflect(readMethod);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException exp) {
String error = String.format("Class %s must have a public %s method", clazz.getName(),
READ_METHOD_NAME);
throw new EntityManagerException(error, exp);
}
} | java | private MethodHandle findIdReadMethod() {
try {
Method readMethod = clazz.getMethod(READ_METHOD_NAME);
Class<?> dataClass = readMethod.getReturnType();
DataType dataType = IdentifierMetadata.DataType.forClass(dataClass);
if (dataType == null) {
String pattern = "Method %s in class %s must have a return type of long, Long or String";
String error = String.format(pattern, READ_METHOD_NAME, clazz.getName());
throw new EntityManagerException(error);
}
return MethodHandles.lookup().unreflect(readMethod);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException exp) {
String error = String.format("Class %s must have a public %s method", clazz.getName(),
READ_METHOD_NAME);
throw new EntityManagerException(error, exp);
}
} | [
"private",
"MethodHandle",
"findIdReadMethod",
"(",
")",
"{",
"try",
"{",
"Method",
"readMethod",
"=",
"clazz",
".",
"getMethod",
"(",
"READ_METHOD_NAME",
")",
";",
"Class",
"<",
"?",
">",
"dataClass",
"=",
"readMethod",
".",
"getReturnType",
"(",
")",
";",
... | Creates and returns the MethodHandle for reading the underlying ID.
@return the MethodHandle for reading the underlying ID. | [
"Creates",
"and",
"returns",
"the",
"MethodHandle",
"for",
"reading",
"the",
"underlying",
"ID",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IdClassMetadata.java#L108-L124 |
134,703 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IdClassMetadata.java | IdClassMetadata.findConstructor | private MethodHandle findConstructor() {
try {
MethodHandle mh = MethodHandles.publicLookup().findConstructor(clazz,
MethodType.methodType(void.class, getIdType()));
return mh;
} catch (NoSuchMethodException | IllegalAccessException exp) {
String pattern = "Class %s requires a public constructor with one parameter of type %s";
String error = String.format(pattern, clazz.getName(), getIdType());
throw new EntityManagerException(error, exp);
}
} | java | private MethodHandle findConstructor() {
try {
MethodHandle mh = MethodHandles.publicLookup().findConstructor(clazz,
MethodType.methodType(void.class, getIdType()));
return mh;
} catch (NoSuchMethodException | IllegalAccessException exp) {
String pattern = "Class %s requires a public constructor with one parameter of type %s";
String error = String.format(pattern, clazz.getName(), getIdType());
throw new EntityManagerException(error, exp);
}
} | [
"private",
"MethodHandle",
"findConstructor",
"(",
")",
"{",
"try",
"{",
"MethodHandle",
"mh",
"=",
"MethodHandles",
".",
"publicLookup",
"(",
")",
".",
"findConstructor",
"(",
"clazz",
",",
"MethodType",
".",
"methodType",
"(",
"void",
".",
"class",
",",
"g... | Creates and returns the MethodHandle for the constructor.
@return the MethodHandle for the constructor. | [
"Creates",
"and",
"returns",
"the",
"MethodHandle",
"for",
"the",
"constructor",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IdClassMetadata.java#L131-L141 |
134,704 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java | IntrospectionUtils.instantiate | public static Object instantiate(MetadataBase metadata) {
try {
return metadata.getConstructorMetadata().getConstructorMethodHandle().invoke();
} catch (Throwable t) {
throw new EntityManagerException(t);
}
} | java | public static Object instantiate(MetadataBase metadata) {
try {
return metadata.getConstructorMetadata().getConstructorMethodHandle().invoke();
} catch (Throwable t) {
throw new EntityManagerException(t);
}
} | [
"public",
"static",
"Object",
"instantiate",
"(",
"MetadataBase",
"metadata",
")",
"{",
"try",
"{",
"return",
"metadata",
".",
"getConstructorMetadata",
"(",
")",
".",
"getConstructorMethodHandle",
"(",
")",
".",
"invoke",
"(",
")",
";",
"}",
"catch",
"(",
"... | Creates and returns a new instance of a persistence class for the given metadata. The returned
object will be an instance of the primary persistence class or its Builder.
@param metadata
the metadata of the class
@return a new instance of the of the Class to which the given metadata belongs.
@throws EntityManagerException
if any error occurs during instantiation. | [
"Creates",
"and",
"returns",
"a",
"new",
"instance",
"of",
"a",
"persistence",
"class",
"for",
"the",
"given",
"metadata",
".",
"The",
"returned",
"object",
"will",
"be",
"an",
"instance",
"of",
"the",
"primary",
"persistence",
"class",
"or",
"its",
"Builder... | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java#L67-L73 |
134,705 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java | IntrospectionUtils.getPropertyMetadata | public static PropertyMetadata getPropertyMetadata(Field field) {
Property property = field.getAnnotation(Property.class);
// For fields that have @Property annotation, we expect both setter and
// getter methods. For all other fields, we only treat them as
// persistable if we find valid getter and setter methods.
try {
PropertyMetadata propertyMetadata = new PropertyMetadata(field);
return propertyMetadata;
} catch (NoAccessorMethodException | NoMutatorMethodException exp) {
if (property != null) {
throw exp;
}
}
return null;
} | java | public static PropertyMetadata getPropertyMetadata(Field field) {
Property property = field.getAnnotation(Property.class);
// For fields that have @Property annotation, we expect both setter and
// getter methods. For all other fields, we only treat them as
// persistable if we find valid getter and setter methods.
try {
PropertyMetadata propertyMetadata = new PropertyMetadata(field);
return propertyMetadata;
} catch (NoAccessorMethodException | NoMutatorMethodException exp) {
if (property != null) {
throw exp;
}
}
return null;
} | [
"public",
"static",
"PropertyMetadata",
"getPropertyMetadata",
"(",
"Field",
"field",
")",
"{",
"Property",
"property",
"=",
"field",
".",
"getAnnotation",
"(",
"Property",
".",
"class",
")",
";",
"// For fields that have @Property annotation, we expect both setter and",
... | Returns the metadata for the given field.
@param field
the field whose metadata has to be prepared
@return metadata of the given field. | [
"Returns",
"the",
"metadata",
"for",
"the",
"given",
"field",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java#L82-L96 |
134,706 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java | IntrospectionUtils.instantiateObject | public static Object instantiateObject(Class<?> clazz) {
try {
Constructor<?> constructor = clazz.getConstructor();
return constructor.newInstance();
} catch (Exception exp) {
throw new EntityManagerException(exp);
}
} | java | public static Object instantiateObject(Class<?> clazz) {
try {
Constructor<?> constructor = clazz.getConstructor();
return constructor.newInstance();
} catch (Exception exp) {
throw new EntityManagerException(exp);
}
} | [
"public",
"static",
"Object",
"instantiateObject",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"try",
"{",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"clazz",
".",
"getConstructor",
"(",
")",
";",
"return",
"constructor",
".",
"newInstance",
"("... | Creates a new object of given class by invoking the class' default public constructor.
@param clazz
the class whose instance needs to be created
@return a new instance of the given class
@throws EntityManagerException
if any error occurs | [
"Creates",
"a",
"new",
"object",
"of",
"given",
"class",
"by",
"invoking",
"the",
"class",
"default",
"public",
"constructor",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java#L258-L266 |
134,707 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java | IntrospectionUtils.getFieldValue | public static Object getFieldValue(FieldMetadata fieldMetadata, Object target) {
MethodHandle readMethod = fieldMetadata.getReadMethod();
try {
return readMethod.invoke(target);
} catch (Throwable t) {
throw new EntityManagerException(t.getMessage(), t);
}
} | java | public static Object getFieldValue(FieldMetadata fieldMetadata, Object target) {
MethodHandle readMethod = fieldMetadata.getReadMethod();
try {
return readMethod.invoke(target);
} catch (Throwable t) {
throw new EntityManagerException(t.getMessage(), t);
}
} | [
"public",
"static",
"Object",
"getFieldValue",
"(",
"FieldMetadata",
"fieldMetadata",
",",
"Object",
"target",
")",
"{",
"MethodHandle",
"readMethod",
"=",
"fieldMetadata",
".",
"getReadMethod",
"(",
")",
";",
"try",
"{",
"return",
"readMethod",
".",
"invoke",
"... | Returns the value of the field represented by the given metadata.
@param fieldMetadata
the metadata of the field
@param target
the target object to which the field belongs.
@return the value of the field. | [
"Returns",
"the",
"value",
"of",
"the",
"field",
"represented",
"by",
"the",
"given",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java#L376-L383 |
134,708 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java | IntrospectionUtils.findStaticMethod | public static MethodHandle findStaticMethod(Class<?> clazz, String methodName,
Class<?> expectedReturnType, Class<?>... expectedParameterTypes) {
return findMethod(clazz, methodName, true, expectedReturnType, expectedParameterTypes);
} | java | public static MethodHandle findStaticMethod(Class<?> clazz, String methodName,
Class<?> expectedReturnType, Class<?>... expectedParameterTypes) {
return findMethod(clazz, methodName, true, expectedReturnType, expectedParameterTypes);
} | [
"public",
"static",
"MethodHandle",
"findStaticMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"expectedReturnType",
",",
"Class",
"<",
"?",
">",
"...",
"expectedParameterTypes",
")",
"{",
"return",
"f... | Finds and returns a MethodHandle for a public static method.
@param clazz
the class to search
@param methodName
the name of the method
@param expectedReturnType
the expected return type. If {@code null}, any return type is treated as valid.
@param expectedParameterTypes
expected parameter types
@return a MethodHandle for the specified criteria. Returns {@code null} if no method exists
with the specified criteria. | [
"Finds",
"and",
"returns",
"a",
"MethodHandle",
"for",
"a",
"public",
"static",
"method",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java#L418-L421 |
134,709 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java | IntrospectionUtils.findInstanceMethod | public static MethodHandle findInstanceMethod(Class<?> clazz, String methodName,
Class<?> expectedReturnType, Class<?>... expectedParameterTypes) {
return findMethod(clazz, methodName, false, expectedReturnType, expectedParameterTypes);
} | java | public static MethodHandle findInstanceMethod(Class<?> clazz, String methodName,
Class<?> expectedReturnType, Class<?>... expectedParameterTypes) {
return findMethod(clazz, methodName, false, expectedReturnType, expectedParameterTypes);
} | [
"public",
"static",
"MethodHandle",
"findInstanceMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"expectedReturnType",
",",
"Class",
"<",
"?",
">",
"...",
"expectedParameterTypes",
")",
"{",
"return",
... | Finds and returns a MethodHandle for a public instance method.
@param clazz
the class to search
@param methodName
the name of the method
@param expectedReturnType
the expected return type. If {@code null}, any return type is treated as valid.
@param expectedParameterTypes
expected parameter types
@return a MethodHandle for the specified criteria. Returns {@code null} if no method exists
with the specified criteria. | [
"Finds",
"and",
"returns",
"a",
"MethodHandle",
"for",
"a",
"public",
"instance",
"method",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java#L437-L440 |
134,710 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java | IntrospectionUtils.findMethod | private static MethodHandle findMethod(Class<?> clazz, String methodName, boolean staticMethod,
Class<?> expectedReturnType, Class<?>... expectedParameterTypes) {
MethodHandle methodHandle = null;
try {
Method method = clazz.getMethod(methodName, expectedParameterTypes);
int modifiers = method.getModifiers();
Class<?> returnType = method.getReturnType();
if (Modifier.isStatic(modifiers) != staticMethod) {
throw new NoSuchMethodException();
}
if (expectedReturnType != null && !expectedReturnType.isAssignableFrom(returnType)) {
throw new NoSuchMethodException();
}
methodHandle = MethodHandles.publicLookup().unreflect(method);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException e) {
// Method not found
}
return methodHandle;
} | java | private static MethodHandle findMethod(Class<?> clazz, String methodName, boolean staticMethod,
Class<?> expectedReturnType, Class<?>... expectedParameterTypes) {
MethodHandle methodHandle = null;
try {
Method method = clazz.getMethod(methodName, expectedParameterTypes);
int modifiers = method.getModifiers();
Class<?> returnType = method.getReturnType();
if (Modifier.isStatic(modifiers) != staticMethod) {
throw new NoSuchMethodException();
}
if (expectedReturnType != null && !expectedReturnType.isAssignableFrom(returnType)) {
throw new NoSuchMethodException();
}
methodHandle = MethodHandles.publicLookup().unreflect(method);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException e) {
// Method not found
}
return methodHandle;
} | [
"private",
"static",
"MethodHandle",
"findMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodName",
",",
"boolean",
"staticMethod",
",",
"Class",
"<",
"?",
">",
"expectedReturnType",
",",
"Class",
"<",
"?",
">",
"...",
"expectedParameterTypes... | Finds and returns a method handle for the given criteria.
@param clazz
the class to search
@param methodName
the name of the method
@param staticMethod
whether the method is static or not
@param expectedReturnType
expected return type
@param expectedParameterTypes
expected parameter types
@return a methodHandle for the specified criteria. Returns {@code null} if no method exists
with the specified criteria. | [
"Finds",
"and",
"returns",
"a",
"method",
"handle",
"for",
"the",
"given",
"criteria",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/IntrospectionUtils.java#L458-L477 |
134,711 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/PropertyMetadata.java | PropertyMetadata.setOptional | public void setOptional(boolean optional) {
if (field.getType().isPrimitive() || field.isAnnotationPresent(Version.class)
|| field.isAnnotationPresent(CreatedTimestamp.class)
|| field.isAnnotationPresent(UpdatedTimestamp.class)) {
this.optional = false;
} else {
this.optional = optional;
}
} | java | public void setOptional(boolean optional) {
if (field.getType().isPrimitive() || field.isAnnotationPresent(Version.class)
|| field.isAnnotationPresent(CreatedTimestamp.class)
|| field.isAnnotationPresent(UpdatedTimestamp.class)) {
this.optional = false;
} else {
this.optional = optional;
}
} | [
"public",
"void",
"setOptional",
"(",
"boolean",
"optional",
")",
"{",
"if",
"(",
"field",
".",
"getType",
"(",
")",
".",
"isPrimitive",
"(",
")",
"||",
"field",
".",
"isAnnotationPresent",
"(",
"Version",
".",
"class",
")",
"||",
"field",
".",
"isAnnota... | Sets whether or not the field represented by this metadata is optional.
@param optional
whether or not the field represented by this metadata is optional. | [
"Sets",
"whether",
"or",
"not",
"the",
"field",
"represented",
"by",
"this",
"metadata",
"is",
"optional",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/PropertyMetadata.java#L197-L205 |
134,712 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/PropertyMetadata.java | PropertyMetadata.initializeSecondaryIndexer | private void initializeSecondaryIndexer() {
SecondaryIndex secondaryIndexAnnotation = field.getAnnotation(SecondaryIndex.class);
if (secondaryIndexAnnotation == null) {
return;
}
String indexName = secondaryIndexAnnotation.name();
if (indexName == null || indexName.trim().length() == 0) {
indexName = DEFAULT_SECONDARY_INDEX_PREFIX + mappedName;
}
this.secondaryIndexName = indexName;
try {
secondaryIndexer = IndexerFactory.getInstance().getIndexer(field);
} catch (Exception exp) {
String pattern = "No suitable Indexer found or error occurred while creating the indexer "
+ "for field %s in class %s";
String message = String.format(pattern, field.getName(), field.getDeclaringClass().getName());
throw new EntityManagerException(message, exp);
}
} | java | private void initializeSecondaryIndexer() {
SecondaryIndex secondaryIndexAnnotation = field.getAnnotation(SecondaryIndex.class);
if (secondaryIndexAnnotation == null) {
return;
}
String indexName = secondaryIndexAnnotation.name();
if (indexName == null || indexName.trim().length() == 0) {
indexName = DEFAULT_SECONDARY_INDEX_PREFIX + mappedName;
}
this.secondaryIndexName = indexName;
try {
secondaryIndexer = IndexerFactory.getInstance().getIndexer(field);
} catch (Exception exp) {
String pattern = "No suitable Indexer found or error occurred while creating the indexer "
+ "for field %s in class %s";
String message = String.format(pattern, field.getName(), field.getDeclaringClass().getName());
throw new EntityManagerException(message, exp);
}
} | [
"private",
"void",
"initializeSecondaryIndexer",
"(",
")",
"{",
"SecondaryIndex",
"secondaryIndexAnnotation",
"=",
"field",
".",
"getAnnotation",
"(",
"SecondaryIndex",
".",
"class",
")",
";",
"if",
"(",
"secondaryIndexAnnotation",
"==",
"null",
")",
"{",
"return",
... | Initializes the secondary indexer for this property, if any. | [
"Initializes",
"the",
"secondary",
"indexer",
"for",
"this",
"property",
"if",
"any",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/PropertyMetadata.java#L210-L229 |
134,713 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java | EntityListenersIntrospector.introspect | public static EntityListenersMetadata introspect(Class<?> entityClass) {
EntityListenersIntrospector introspector = new EntityListenersIntrospector(entityClass);
introspector.introspect();
return introspector.metadata;
} | java | public static EntityListenersMetadata introspect(Class<?> entityClass) {
EntityListenersIntrospector introspector = new EntityListenersIntrospector(entityClass);
introspector.introspect();
return introspector.metadata;
} | [
"public",
"static",
"EntityListenersMetadata",
"introspect",
"(",
"Class",
"<",
"?",
">",
"entityClass",
")",
"{",
"EntityListenersIntrospector",
"introspector",
"=",
"new",
"EntityListenersIntrospector",
"(",
"entityClass",
")",
";",
"introspector",
".",
"introspect",
... | Returns the metadata of various registered listeners for the given entity class.
@param entityClass
the entity class to introspect
@return the metadata of various listeners. | [
"Returns",
"the",
"metadata",
"of",
"various",
"registered",
"listeners",
"for",
"the",
"given",
"entity",
"class",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java#L77-L81 |
134,714 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java | EntityListenersIntrospector.getAllExternalListeners | private List<Class<?>> getAllExternalListeners() {
Class<?> clazz = entityClass;
List<Class<?>> allListeners = new ArrayList<>();
boolean stop = false;
while (!stop) {
EntityListeners entityListenersAnnotation = clazz.getAnnotation(EntityListeners.class);
if (entityListenersAnnotation != null) {
Class<?>[] listeners = entityListenersAnnotation.value();
if (listeners.length > 0) {
allListeners.addAll(0, Arrays.asList(listeners));
}
}
boolean excludeDefaultListeners = clazz.isAnnotationPresent(ExcludeDefaultListeners.class);
boolean excludeSuperClassListeners = clazz
.isAnnotationPresent(ExcludeSuperclassListeners.class);
if (excludeDefaultListeners) {
metadata.setExcludeDefaultListeners(true);
}
if (excludeSuperClassListeners) {
metadata.setExcludeSuperClassListeners(true);
}
clazz = clazz.getSuperclass();
stop = excludeSuperClassListeners || clazz == null
|| !clazz.isAnnotationPresent(MappedSuperClass.class);
}
return allListeners;
} | java | private List<Class<?>> getAllExternalListeners() {
Class<?> clazz = entityClass;
List<Class<?>> allListeners = new ArrayList<>();
boolean stop = false;
while (!stop) {
EntityListeners entityListenersAnnotation = clazz.getAnnotation(EntityListeners.class);
if (entityListenersAnnotation != null) {
Class<?>[] listeners = entityListenersAnnotation.value();
if (listeners.length > 0) {
allListeners.addAll(0, Arrays.asList(listeners));
}
}
boolean excludeDefaultListeners = clazz.isAnnotationPresent(ExcludeDefaultListeners.class);
boolean excludeSuperClassListeners = clazz
.isAnnotationPresent(ExcludeSuperclassListeners.class);
if (excludeDefaultListeners) {
metadata.setExcludeDefaultListeners(true);
}
if (excludeSuperClassListeners) {
metadata.setExcludeSuperClassListeners(true);
}
clazz = clazz.getSuperclass();
stop = excludeSuperClassListeners || clazz == null
|| !clazz.isAnnotationPresent(MappedSuperClass.class);
}
return allListeners;
} | [
"private",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"getAllExternalListeners",
"(",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"entityClass",
";",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"allListeners",
"=",
"new",
"ArrayList",
"<>",
"(",
")"... | Inspects the entity hierarchy and returns all external listeners.
@return list of all external listeners | [
"Inspects",
"the",
"entity",
"hierarchy",
"and",
"returns",
"all",
"external",
"listeners",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java#L108-L134 |
134,715 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java | EntityListenersIntrospector.processExternalListener | private void processExternalListener(Class<?> listenerClass) {
ExternalListenerMetadata listenerMetadata = ExternalListenerIntrospector
.introspect(listenerClass);
Map<CallbackType, Method> callbacks = listenerMetadata.getCallbacks();
if (callbacks != null) {
for (Map.Entry<CallbackType, Method> entry : callbacks.entrySet()) {
validateExternalCallback(entry.getValue(), entry.getKey());
}
}
} | java | private void processExternalListener(Class<?> listenerClass) {
ExternalListenerMetadata listenerMetadata = ExternalListenerIntrospector
.introspect(listenerClass);
Map<CallbackType, Method> callbacks = listenerMetadata.getCallbacks();
if (callbacks != null) {
for (Map.Entry<CallbackType, Method> entry : callbacks.entrySet()) {
validateExternalCallback(entry.getValue(), entry.getKey());
}
}
} | [
"private",
"void",
"processExternalListener",
"(",
"Class",
"<",
"?",
">",
"listenerClass",
")",
"{",
"ExternalListenerMetadata",
"listenerMetadata",
"=",
"ExternalListenerIntrospector",
".",
"introspect",
"(",
"listenerClass",
")",
";",
"Map",
"<",
"CallbackType",
",... | Introspects the given listener class and finds all methods that should receive callback event
notifications.
@param listenerClass
the listener class | [
"Introspects",
"the",
"given",
"listener",
"class",
"and",
"finds",
"all",
"methods",
"that",
"should",
"receive",
"callback",
"event",
"notifications",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java#L143-L152 |
134,716 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java | EntityListenersIntrospector.validateExternalCallback | private void validateExternalCallback(Method method, CallbackType callbackType) {
Class<?>[] parameters = method.getParameterTypes();
if (!parameters[0].isAssignableFrom(entityClass)) {
String message = String.format("Method %s in class %s is not valid for entity %s",
method.getName(), method.getDeclaringClass().getName(), entityClass.getName());
throw new EntityManagerException(message);
}
CallbackMetadata callbackMetadata = new CallbackMetadata(EntityListenerType.EXTERNAL,
callbackType, method);
metadata.put(callbackType, callbackMetadata);
} | java | private void validateExternalCallback(Method method, CallbackType callbackType) {
Class<?>[] parameters = method.getParameterTypes();
if (!parameters[0].isAssignableFrom(entityClass)) {
String message = String.format("Method %s in class %s is not valid for entity %s",
method.getName(), method.getDeclaringClass().getName(), entityClass.getName());
throw new EntityManagerException(message);
}
CallbackMetadata callbackMetadata = new CallbackMetadata(EntityListenerType.EXTERNAL,
callbackType, method);
metadata.put(callbackType, callbackMetadata);
} | [
"private",
"void",
"validateExternalCallback",
"(",
"Method",
"method",
",",
"CallbackType",
"callbackType",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"parameters",
"=",
"method",
".",
"getParameterTypes",
"(",
")",
";",
"if",
"(",
"!",
"parameters",
"[",
... | Validates and registers the given callback method.
@param method
the callback method
@param callbackType
the callback type | [
"Validates",
"and",
"registers",
"the",
"given",
"callback",
"method",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java#L162-L172 |
134,717 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java | EntityListenersIntrospector.processInternalListeners | private void processInternalListeners() {
List<Class<?>> internalListeners = getAllInternalListeners();
for (Class<?> internalListener : internalListeners) {
processInternalListener(internalListener);
}
} | java | private void processInternalListeners() {
List<Class<?>> internalListeners = getAllInternalListeners();
for (Class<?> internalListener : internalListeners) {
processInternalListener(internalListener);
}
} | [
"private",
"void",
"processInternalListeners",
"(",
")",
"{",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"internalListeners",
"=",
"getAllInternalListeners",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"internalListener",
":",
"internalListeners",
")",
... | Introspects the entity class hierarchy for any internal callback methods and updates the
metadata. | [
"Introspects",
"the",
"entity",
"class",
"hierarchy",
"for",
"any",
"internal",
"callback",
"methods",
"and",
"updates",
"the",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java#L178-L183 |
134,718 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java | EntityListenersIntrospector.getAllInternalListeners | private List<Class<?>> getAllInternalListeners() {
Class<?> clazz = entityClass;
List<Class<?>> allListeners = new ArrayList<>();
boolean stop = false;
while (!stop) {
allListeners.add(0, clazz);
boolean excludeSuperClassListeners = clazz
.isAnnotationPresent(ExcludeSuperclassListeners.class);
clazz = clazz.getSuperclass();
stop = excludeSuperClassListeners || clazz == null
|| !clazz.isAnnotationPresent(MappedSuperClass.class);
}
return allListeners;
} | java | private List<Class<?>> getAllInternalListeners() {
Class<?> clazz = entityClass;
List<Class<?>> allListeners = new ArrayList<>();
boolean stop = false;
while (!stop) {
allListeners.add(0, clazz);
boolean excludeSuperClassListeners = clazz
.isAnnotationPresent(ExcludeSuperclassListeners.class);
clazz = clazz.getSuperclass();
stop = excludeSuperClassListeners || clazz == null
|| !clazz.isAnnotationPresent(MappedSuperClass.class);
}
return allListeners;
} | [
"private",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"getAllInternalListeners",
"(",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"entityClass",
";",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"allListeners",
"=",
"new",
"ArrayList",
"<>",
"(",
")"... | Traverses up the entity class hierarchy and returns the list of all classes that may
potentially have callback listeners.
@return all internal callback listeners | [
"Traverses",
"up",
"the",
"entity",
"class",
"hierarchy",
"and",
"returns",
"the",
"list",
"of",
"all",
"classes",
"that",
"may",
"potentially",
"have",
"callback",
"listeners",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java#L191-L205 |
134,719 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java | EntityListenersIntrospector.processInternalListener | private void processInternalListener(Class<?> listenerClass) {
InternalListenerMetadata listenerMetadata = InternalListenerIntrospector
.introspect(listenerClass);
Map<CallbackType, Method> callbacks = listenerMetadata.getCallbacks();
if (callbacks != null) {
for (Map.Entry<CallbackType, Method> entry : callbacks.entrySet()) {
CallbackType callbackType = entry.getKey();
Method callbackMethod = entry.getValue();
CallbackMetadata callbackMetadata = new CallbackMetadata(EntityListenerType.INTERNAL,
callbackType, callbackMethod);
metadata.put(callbackType, callbackMetadata);
}
}
} | java | private void processInternalListener(Class<?> listenerClass) {
InternalListenerMetadata listenerMetadata = InternalListenerIntrospector
.introspect(listenerClass);
Map<CallbackType, Method> callbacks = listenerMetadata.getCallbacks();
if (callbacks != null) {
for (Map.Entry<CallbackType, Method> entry : callbacks.entrySet()) {
CallbackType callbackType = entry.getKey();
Method callbackMethod = entry.getValue();
CallbackMetadata callbackMetadata = new CallbackMetadata(EntityListenerType.INTERNAL,
callbackType, callbackMethod);
metadata.put(callbackType, callbackMetadata);
}
}
} | [
"private",
"void",
"processInternalListener",
"(",
"Class",
"<",
"?",
">",
"listenerClass",
")",
"{",
"InternalListenerMetadata",
"listenerMetadata",
"=",
"InternalListenerIntrospector",
".",
"introspect",
"(",
"listenerClass",
")",
";",
"Map",
"<",
"CallbackType",
",... | Processes the given class and finds any internal callbacks.
@param listenerClass
the class to introspect | [
"Processes",
"the",
"given",
"class",
"and",
"finds",
"any",
"internal",
"callbacks",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersIntrospector.java#L213-L226 |
134,720 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/ListenerFactory.java | ListenerFactory.getListener | public Object getListener(Class<?> listenerClass) {
Object listener = listeners.get(listenerClass);
if (listener == null) {
listener = loadListener(listenerClass);
}
return listener;
} | java | public Object getListener(Class<?> listenerClass) {
Object listener = listeners.get(listenerClass);
if (listener == null) {
listener = loadListener(listenerClass);
}
return listener;
} | [
"public",
"Object",
"getListener",
"(",
"Class",
"<",
"?",
">",
"listenerClass",
")",
"{",
"Object",
"listener",
"=",
"listeners",
".",
"get",
"(",
"listenerClass",
")",
";",
"if",
"(",
"listener",
"==",
"null",
")",
"{",
"listener",
"=",
"loadListener",
... | Returns the listener object for the given class.
@param listenerClass
the listener class
@return the listener object for the given type | [
"Returns",
"the",
"listener",
"object",
"for",
"the",
"given",
"class",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/ListenerFactory.java#L55-L61 |
134,721 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/ListenerFactory.java | ListenerFactory.loadListener | private Object loadListener(Class<?> listenerClass) {
synchronized (listenerClass) {
Object listener = listeners.get(listenerClass);
if (listener == null) {
listener = IntrospectionUtils.instantiateObject(listenerClass);
listeners.put(listenerClass, listener);
}
return listener;
}
} | java | private Object loadListener(Class<?> listenerClass) {
synchronized (listenerClass) {
Object listener = listeners.get(listenerClass);
if (listener == null) {
listener = IntrospectionUtils.instantiateObject(listenerClass);
listeners.put(listenerClass, listener);
}
return listener;
}
} | [
"private",
"Object",
"loadListener",
"(",
"Class",
"<",
"?",
">",
"listenerClass",
")",
"{",
"synchronized",
"(",
"listenerClass",
")",
"{",
"Object",
"listener",
"=",
"listeners",
".",
"get",
"(",
"listenerClass",
")",
";",
"if",
"(",
"listener",
"==",
"n... | Instantiates the listener of given type and caches it.
@param listenerClass
the listener type
@return the instantiated object | [
"Instantiates",
"the",
"listener",
"of",
"given",
"type",
"and",
"caches",
"it",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/ListenerFactory.java#L79-L88 |
134,722 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddableIntrospector.java | EmbeddableIntrospector.introspect | public static EmbeddableMetadata introspect(Class<?> embeddableClass) {
EmbeddableIntrospector introspector = new EmbeddableIntrospector(embeddableClass);
introspector.introspect();
return introspector.metadata;
} | java | public static EmbeddableMetadata introspect(Class<?> embeddableClass) {
EmbeddableIntrospector introspector = new EmbeddableIntrospector(embeddableClass);
introspector.introspect();
return introspector.metadata;
} | [
"public",
"static",
"EmbeddableMetadata",
"introspect",
"(",
"Class",
"<",
"?",
">",
"embeddableClass",
")",
"{",
"EmbeddableIntrospector",
"introspector",
"=",
"new",
"EmbeddableIntrospector",
"(",
"embeddableClass",
")",
";",
"introspector",
".",
"introspect",
"(",
... | Introspects the given Embeddable class and returns the metadata.
@param embeddableClass
the Embeddable class
@return the metadata of the given class | [
"Introspects",
"the",
"given",
"Embeddable",
"class",
"and",
"returns",
"the",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddableIntrospector.java#L61-L65 |
134,723 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddableIntrospector.java | EmbeddableIntrospector.introspect | private void introspect() {
// Make sure the class is Embeddable
if (!embeddableClass.isAnnotationPresent(Embeddable.class)) {
String message = String.format("Class %s must have %s annotation", embeddableClass.getName(),
Embeddable.class.getName());
throw new EntityManagerException(message);
}
metadata = new EmbeddableMetadata(embeddableClass);
processFields();
} | java | private void introspect() {
// Make sure the class is Embeddable
if (!embeddableClass.isAnnotationPresent(Embeddable.class)) {
String message = String.format("Class %s must have %s annotation", embeddableClass.getName(),
Embeddable.class.getName());
throw new EntityManagerException(message);
}
metadata = new EmbeddableMetadata(embeddableClass);
processFields();
} | [
"private",
"void",
"introspect",
"(",
")",
"{",
"// Make sure the class is Embeddable",
"if",
"(",
"!",
"embeddableClass",
".",
"isAnnotationPresent",
"(",
"Embeddable",
".",
"class",
")",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Clas... | Introspects the Embeddable. | [
"Introspects",
"the",
"Embeddable",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddableIntrospector.java#L70-L79 |
134,724 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddableIntrospector.java | EmbeddableIntrospector.processFields | private void processFields() {
List<Field> fields = IntrospectionUtils.getPersistableFields(embeddableClass);
for (Field field : fields) {
if (field.isAnnotationPresent(Embedded.class)) {
processEmbeddedField(field);
} else {
processSimpleField(field);
}
}
} | java | private void processFields() {
List<Field> fields = IntrospectionUtils.getPersistableFields(embeddableClass);
for (Field field : fields) {
if (field.isAnnotationPresent(Embedded.class)) {
processEmbeddedField(field);
} else {
processSimpleField(field);
}
}
} | [
"private",
"void",
"processFields",
"(",
")",
"{",
"List",
"<",
"Field",
">",
"fields",
"=",
"IntrospectionUtils",
".",
"getPersistableFields",
"(",
"embeddableClass",
")",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"if",
"(",
"field",
"."... | Processes each field in this Embeddable and updates the metadata. | [
"Processes",
"each",
"field",
"in",
"this",
"Embeddable",
"and",
"updates",
"the",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddableIntrospector.java#L84-L93 |
134,725 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddedIntrospector.java | EmbeddedIntrospector.introspect | public static EmbeddedMetadata introspect(EmbeddedField field, EntityMetadata entityMetadata) {
EmbeddedIntrospector introspector = new EmbeddedIntrospector(field, entityMetadata);
introspector.process();
return introspector.metadata;
} | java | public static EmbeddedMetadata introspect(EmbeddedField field, EntityMetadata entityMetadata) {
EmbeddedIntrospector introspector = new EmbeddedIntrospector(field, entityMetadata);
introspector.process();
return introspector.metadata;
} | [
"public",
"static",
"EmbeddedMetadata",
"introspect",
"(",
"EmbeddedField",
"field",
",",
"EntityMetadata",
"entityMetadata",
")",
"{",
"EmbeddedIntrospector",
"introspector",
"=",
"new",
"EmbeddedIntrospector",
"(",
"field",
",",
"entityMetadata",
")",
";",
"introspect... | Introspects the given embedded field and returns its metadata.
@param field
the embedded field to introspect
@param entityMetadata
metadata of the owning entity
@return the metadata of the embedded field | [
"Introspects",
"the",
"given",
"embedded",
"field",
"and",
"returns",
"its",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddedIntrospector.java#L80-L84 |
134,726 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddedIntrospector.java | EmbeddedIntrospector.process | private void process() {
metadata = new EmbeddedMetadata(field);
// Make sure the class has @Embeddable annotation
if (!clazz.isAnnotationPresent(Embeddable.class)) {
String message = String.format("Class %s must have %s annotation", clazz.getName(),
Embeddable.class.getName());
throw new EntityManagerException(message);
}
// Check the mapped name and indexed attributes
Embedded embeddedAnnotation = field.getField().getAnnotation(Embedded.class);
String mappedName = embeddedAnnotation.name();
if (mappedName == null || mappedName.trim().length() == 0) {
mappedName = field.getName();
}
metadata.setMappedName(mappedName);
metadata.setIndexed(embeddedAnnotation.indexed());
metadata.setOptional(embeddedAnnotation.optional());
// If there is an annotation for storing the embedded with Imploded
// strategy...
if (field.getField().isAnnotationPresent(Imploded.class)) {
metadata.setStorageStrategy(StorageStrategy.IMPLODED);
}
processFields();
} | java | private void process() {
metadata = new EmbeddedMetadata(field);
// Make sure the class has @Embeddable annotation
if (!clazz.isAnnotationPresent(Embeddable.class)) {
String message = String.format("Class %s must have %s annotation", clazz.getName(),
Embeddable.class.getName());
throw new EntityManagerException(message);
}
// Check the mapped name and indexed attributes
Embedded embeddedAnnotation = field.getField().getAnnotation(Embedded.class);
String mappedName = embeddedAnnotation.name();
if (mappedName == null || mappedName.trim().length() == 0) {
mappedName = field.getName();
}
metadata.setMappedName(mappedName);
metadata.setIndexed(embeddedAnnotation.indexed());
metadata.setOptional(embeddedAnnotation.optional());
// If there is an annotation for storing the embedded with Imploded
// strategy...
if (field.getField().isAnnotationPresent(Imploded.class)) {
metadata.setStorageStrategy(StorageStrategy.IMPLODED);
}
processFields();
} | [
"private",
"void",
"process",
"(",
")",
"{",
"metadata",
"=",
"new",
"EmbeddedMetadata",
"(",
"field",
")",
";",
"// Make sure the class has @Embeddable annotation",
"if",
"(",
"!",
"clazz",
".",
"isAnnotationPresent",
"(",
"Embeddable",
".",
"class",
")",
")",
... | Worker class for introspection. | [
"Worker",
"class",
"for",
"introspection",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddedIntrospector.java#L89-L115 |
134,727 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddedIntrospector.java | EmbeddedIntrospector.processFields | private void processFields() {
List<Field> children = IntrospectionUtils.getPersistableFields(clazz);
for (Field child : children) {
if (child.isAnnotationPresent(Embedded.class)) {
processEmbeddedField(child);
} else {
processSimpleField(child);
}
}
} | java | private void processFields() {
List<Field> children = IntrospectionUtils.getPersistableFields(clazz);
for (Field child : children) {
if (child.isAnnotationPresent(Embedded.class)) {
processEmbeddedField(child);
} else {
processSimpleField(child);
}
}
} | [
"private",
"void",
"processFields",
"(",
")",
"{",
"List",
"<",
"Field",
">",
"children",
"=",
"IntrospectionUtils",
".",
"getPersistableFields",
"(",
"clazz",
")",
";",
"for",
"(",
"Field",
"child",
":",
"children",
")",
"{",
"if",
"(",
"child",
".",
"i... | Processes each field in this embedded object and updates the metadata. | [
"Processes",
"each",
"field",
"in",
"this",
"embedded",
"object",
"and",
"updates",
"the",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddedIntrospector.java#L120-L129 |
134,728 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddedIntrospector.java | EmbeddedIntrospector.processPropertyOverride | private void processPropertyOverride(PropertyMetadata propertyMetadata) {
String qualifiedName = field.getQualifiedName() + "." + propertyMetadata.getField().getName();
Property override = entityMetadata.getPropertyOverride(qualifiedName);
if (override != null) {
String mappedName = override.name();
if (mappedName != null && mappedName.trim().length() > 0) {
propertyMetadata.setMappedName(mappedName);
}
propertyMetadata.setIndexed(override.indexed());
propertyMetadata.setOptional(override.optional());
}
} | java | private void processPropertyOverride(PropertyMetadata propertyMetadata) {
String qualifiedName = field.getQualifiedName() + "." + propertyMetadata.getField().getName();
Property override = entityMetadata.getPropertyOverride(qualifiedName);
if (override != null) {
String mappedName = override.name();
if (mappedName != null && mappedName.trim().length() > 0) {
propertyMetadata.setMappedName(mappedName);
}
propertyMetadata.setIndexed(override.indexed());
propertyMetadata.setOptional(override.optional());
}
} | [
"private",
"void",
"processPropertyOverride",
"(",
"PropertyMetadata",
"propertyMetadata",
")",
"{",
"String",
"qualifiedName",
"=",
"field",
".",
"getQualifiedName",
"(",
")",
"+",
"\".\"",
"+",
"propertyMetadata",
".",
"getField",
"(",
")",
".",
"getName",
"(",
... | Processes the override, if any, for the given property.
@param propertyMetadata
the metadata of the property | [
"Processes",
"the",
"override",
"if",
"any",
"for",
"the",
"given",
"property",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddedIntrospector.java#L152-L163 |
134,729 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.validateIntent | private void validateIntent() {
if (entityMetadata.isProjectedEntity() && !intent.isValidOnProjectedEntities()) {
String message = String.format("Operation %s is not allowed for ProjectedEntity %s", intent,
entity.getClass().getName());
throw new EntityManagerException(message);
}
} | java | private void validateIntent() {
if (entityMetadata.isProjectedEntity() && !intent.isValidOnProjectedEntities()) {
String message = String.format("Operation %s is not allowed for ProjectedEntity %s", intent,
entity.getClass().getName());
throw new EntityManagerException(message);
}
} | [
"private",
"void",
"validateIntent",
"(",
")",
"{",
"if",
"(",
"entityMetadata",
".",
"isProjectedEntity",
"(",
")",
"&&",
"!",
"intent",
".",
"isValidOnProjectedEntities",
"(",
")",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Operat... | Validates if the Intent is legal for the entity being marshalled.
@throws EntityManagerException
if the Intent is not valid for the entity being marshalled | [
"Validates",
"if",
"the",
"Intent",
"is",
"legal",
"for",
"the",
"entity",
"being",
"marshalled",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L183-L189 |
134,730 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshal | private BaseEntity<?> marshal() {
marshalKey();
if (key instanceof Key) {
entityBuilder = Entity.newBuilder((Key) key);
} else {
entityBuilder = FullEntity.newBuilder(key);
}
marshalFields();
marshalAutoTimestampFields();
if (intent == Intent.UPDATE) {
marshalVersionField();
}
marshalEmbeddedFields();
return entityBuilder.build();
} | java | private BaseEntity<?> marshal() {
marshalKey();
if (key instanceof Key) {
entityBuilder = Entity.newBuilder((Key) key);
} else {
entityBuilder = FullEntity.newBuilder(key);
}
marshalFields();
marshalAutoTimestampFields();
if (intent == Intent.UPDATE) {
marshalVersionField();
}
marshalEmbeddedFields();
return entityBuilder.build();
} | [
"private",
"BaseEntity",
"<",
"?",
">",
"marshal",
"(",
")",
"{",
"marshalKey",
"(",
")",
";",
"if",
"(",
"key",
"instanceof",
"Key",
")",
"{",
"entityBuilder",
"=",
"Entity",
".",
"newBuilder",
"(",
"(",
"Key",
")",
"key",
")",
";",
"}",
"else",
"... | Marshals the given entity and and returns the equivalent Entity needed for the underlying Cloud
Datastore API.
@return A native entity that is equivalent to the POJO being marshalled. The returned value
could either be a FullEntity or Entity. | [
"Marshals",
"the",
"given",
"entity",
"and",
"and",
"returns",
"the",
"equivalent",
"Entity",
"needed",
"for",
"the",
"underlying",
"Cloud",
"Datastore",
"API",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L219-L233 |
134,731 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalKey | public static Key marshalKey(DefaultEntityManager entityManager, Object entity) {
Marshaller marshaller = new Marshaller(entityManager, entity, Intent.DELETE);
marshaller.marshalKey();
return (Key) marshaller.key;
} | java | public static Key marshalKey(DefaultEntityManager entityManager, Object entity) {
Marshaller marshaller = new Marshaller(entityManager, entity, Intent.DELETE);
marshaller.marshalKey();
return (Key) marshaller.key;
} | [
"public",
"static",
"Key",
"marshalKey",
"(",
"DefaultEntityManager",
"entityManager",
",",
"Object",
"entity",
")",
"{",
"Marshaller",
"marshaller",
"=",
"new",
"Marshaller",
"(",
"entityManager",
",",
"entity",
",",
"Intent",
".",
"DELETE",
")",
";",
"marshall... | Extracts the key from the given object, entity, and returns it. The entity must have its ID
set.
@param entityManager
the entity manager.
@param entity
the entity from which key is to be extracted
@return extracted key. | [
"Extracts",
"the",
"key",
"from",
"the",
"given",
"object",
"entity",
"and",
"returns",
"it",
".",
"The",
"entity",
"must",
"have",
"its",
"ID",
"set",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L245-L249 |
134,732 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalKey | private void marshalKey() {
Key parent = null;
ParentKeyMetadata parentKeyMetadata = entityMetadata.getParentKeyMetadata();
if (parentKeyMetadata != null) {
DatastoreKey parentDatastoreKey = (DatastoreKey) getFieldValue(parentKeyMetadata);
if (parentDatastoreKey != null) {
parent = parentDatastoreKey.nativeKey();
}
}
IdentifierMetadata identifierMetadata = entityMetadata.getIdentifierMetadata();
IdClassMetadata idClassMetadata = identifierMetadata.getIdClassMetadata();
DataType identifierType = identifierMetadata.getDataType();
Object idValue = getFieldValue(identifierMetadata);
// If ID value is null, we don't have to worry about if it is a simple
// type of a complex type. Otherwise, we need to see if the ID is a
// complex type, and if it is, extract the real ID.
if (idValue != null && idClassMetadata != null) {
try {
idValue = idClassMetadata.getReadMethod().invoke(idValue);
} catch (Throwable t) {
throw new EntityManagerException(t);
}
}
boolean validId = isValidId(idValue, identifierType);
boolean autoGenerateId = identifierMetadata.isAutoGenerated();
if (validId) {
if (identifierType == DataType.STRING) {
createCompleteKey(parent, (String) idValue);
} else {
createCompleteKey(parent, (long) idValue);
}
} else {
if (intent.isKeyRequired()) {
throw new EntityManagerException(String
.format("Identifier is not set or valid for entity of type %s", entity.getClass()));
}
if (!autoGenerateId) {
String pattern = "Identifier is not set or valid for entity of type %s. Auto generation "
+ "of ID is explicitly turned off. ";
throw new EntityManagerException(String.format(pattern, entity.getClass()));
} else {
if (identifierType == DataType.STRING) {
createCompleteKey(parent);
} else {
createIncompleteKey(parent);
}
}
}
} | java | private void marshalKey() {
Key parent = null;
ParentKeyMetadata parentKeyMetadata = entityMetadata.getParentKeyMetadata();
if (parentKeyMetadata != null) {
DatastoreKey parentDatastoreKey = (DatastoreKey) getFieldValue(parentKeyMetadata);
if (parentDatastoreKey != null) {
parent = parentDatastoreKey.nativeKey();
}
}
IdentifierMetadata identifierMetadata = entityMetadata.getIdentifierMetadata();
IdClassMetadata idClassMetadata = identifierMetadata.getIdClassMetadata();
DataType identifierType = identifierMetadata.getDataType();
Object idValue = getFieldValue(identifierMetadata);
// If ID value is null, we don't have to worry about if it is a simple
// type of a complex type. Otherwise, we need to see if the ID is a
// complex type, and if it is, extract the real ID.
if (idValue != null && idClassMetadata != null) {
try {
idValue = idClassMetadata.getReadMethod().invoke(idValue);
} catch (Throwable t) {
throw new EntityManagerException(t);
}
}
boolean validId = isValidId(idValue, identifierType);
boolean autoGenerateId = identifierMetadata.isAutoGenerated();
if (validId) {
if (identifierType == DataType.STRING) {
createCompleteKey(parent, (String) idValue);
} else {
createCompleteKey(parent, (long) idValue);
}
} else {
if (intent.isKeyRequired()) {
throw new EntityManagerException(String
.format("Identifier is not set or valid for entity of type %s", entity.getClass()));
}
if (!autoGenerateId) {
String pattern = "Identifier is not set or valid for entity of type %s. Auto generation "
+ "of ID is explicitly turned off. ";
throw new EntityManagerException(String.format(pattern, entity.getClass()));
} else {
if (identifierType == DataType.STRING) {
createCompleteKey(parent);
} else {
createIncompleteKey(parent);
}
}
}
} | [
"private",
"void",
"marshalKey",
"(",
")",
"{",
"Key",
"parent",
"=",
"null",
";",
"ParentKeyMetadata",
"parentKeyMetadata",
"=",
"entityMetadata",
".",
"getParentKeyMetadata",
"(",
")",
";",
"if",
"(",
"parentKeyMetadata",
"!=",
"null",
")",
"{",
"DatastoreKey"... | Marshals the key. | [
"Marshals",
"the",
"key",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L254-L308 |
134,733 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.isValidId | private static boolean isValidId(Object idValue, DataType identifierType) {
boolean validId = false;
if (idValue != null) {
switch (identifierType) {
case LONG:
case LONG_OBJECT:
validId = (long) idValue != 0;
break;
case STRING:
validId = ((String) idValue).trim().length() > 0;
break;
default:
// we should never get here
break;
}
}
return validId;
} | java | private static boolean isValidId(Object idValue, DataType identifierType) {
boolean validId = false;
if (idValue != null) {
switch (identifierType) {
case LONG:
case LONG_OBJECT:
validId = (long) idValue != 0;
break;
case STRING:
validId = ((String) idValue).trim().length() > 0;
break;
default:
// we should never get here
break;
}
}
return validId;
} | [
"private",
"static",
"boolean",
"isValidId",
"(",
"Object",
"idValue",
",",
"DataType",
"identifierType",
")",
"{",
"boolean",
"validId",
"=",
"false",
";",
"if",
"(",
"idValue",
"!=",
"null",
")",
"{",
"switch",
"(",
"identifierType",
")",
"{",
"case",
"L... | Checks to see if the given value is a valid identifier for the given ID type.
@param idValue
the ID value
@param identifierType
the identifier type
@return <code>true</code>, if the given value is a valid identifier; <code>false</code>,
otherwise. For STRING type, the ID is valid if it it contains at least one printable
character. In other words, if ((String) idValue).trim().length() > 0. For numeric
types, the ID is valid if it is not <code>null</code> or zero. | [
"Checks",
"to",
"see",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"identifier",
"for",
"the",
"given",
"ID",
"type",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L322-L339 |
134,734 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.createCompleteKey | private void createCompleteKey(Key parent, long id) {
String kind = entityMetadata.getKind();
if (parent == null) {
key = entityManager.newNativeKeyFactory().setKind(kind).newKey(id);
} else {
key = Key.newBuilder(parent, kind, id).build();
}
} | java | private void createCompleteKey(Key parent, long id) {
String kind = entityMetadata.getKind();
if (parent == null) {
key = entityManager.newNativeKeyFactory().setKind(kind).newKey(id);
} else {
key = Key.newBuilder(parent, kind, id).build();
}
} | [
"private",
"void",
"createCompleteKey",
"(",
"Key",
"parent",
",",
"long",
"id",
")",
"{",
"String",
"kind",
"=",
"entityMetadata",
".",
"getKind",
"(",
")",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"key",
"=",
"entityManager",
".",
"newNativeKe... | Creates a complete key using the given parameters.
@param parent
the parent key, may be <code>null</code>.
@param id
the numeric ID | [
"Creates",
"a",
"complete",
"key",
"using",
"the",
"given",
"parameters",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L349-L356 |
134,735 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.createIncompleteKey | private void createIncompleteKey(Key parent) {
String kind = entityMetadata.getKind();
if (parent == null) {
key = entityManager.newNativeKeyFactory().setKind(kind).newKey();
} else {
key = IncompleteKey.newBuilder(parent, kind).build();
}
} | java | private void createIncompleteKey(Key parent) {
String kind = entityMetadata.getKind();
if (parent == null) {
key = entityManager.newNativeKeyFactory().setKind(kind).newKey();
} else {
key = IncompleteKey.newBuilder(parent, kind).build();
}
} | [
"private",
"void",
"createIncompleteKey",
"(",
"Key",
"parent",
")",
"{",
"String",
"kind",
"=",
"entityMetadata",
".",
"getKind",
"(",
")",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"key",
"=",
"entityManager",
".",
"newNativeKeyFactory",
"(",
")"... | Creates an IncompleteKey.
@param parent
the parent key, may be <code>null</code>. | [
"Creates",
"an",
"IncompleteKey",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L398-L405 |
134,736 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalFields | private void marshalFields() {
Collection<PropertyMetadata> propertyMetadataCollection = entityMetadata
.getPropertyMetadataCollection();
for (PropertyMetadata propertyMetadata : propertyMetadataCollection) {
marshalField(propertyMetadata, entity);
}
} | java | private void marshalFields() {
Collection<PropertyMetadata> propertyMetadataCollection = entityMetadata
.getPropertyMetadataCollection();
for (PropertyMetadata propertyMetadata : propertyMetadataCollection) {
marshalField(propertyMetadata, entity);
}
} | [
"private",
"void",
"marshalFields",
"(",
")",
"{",
"Collection",
"<",
"PropertyMetadata",
">",
"propertyMetadataCollection",
"=",
"entityMetadata",
".",
"getPropertyMetadataCollection",
"(",
")",
";",
"for",
"(",
"PropertyMetadata",
"propertyMetadata",
":",
"propertyMet... | Marshals all the fields. | [
"Marshals",
"all",
"the",
"fields",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L410-L416 |
134,737 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalField | private static void marshalField(PropertyMetadata propertyMetadata, Object target,
BaseEntity.Builder<?, ?> entityBuilder) {
Object fieldValue = IntrospectionUtils.getFieldValue(propertyMetadata, target);
if (fieldValue == null && propertyMetadata.isOptional()) {
return;
}
ValueBuilder<?, ?, ?> valueBuilder = propertyMetadata.getMapper().toDatastore(fieldValue);
// ListValues cannot have indexing turned off. Indexing is turned on by
// default, so we don't touch excludeFromIndexes for ListValues.
if (valueBuilder.getValueType() != ValueType.LIST) {
valueBuilder.setExcludeFromIndexes(!propertyMetadata.isIndexed());
}
Value<?> datastoreValue = valueBuilder.build();
entityBuilder.set(propertyMetadata.getMappedName(), datastoreValue);
Indexer indexer = propertyMetadata.getSecondaryIndexer();
if (indexer != null) {
entityBuilder.set(propertyMetadata.getSecondaryIndexName(), indexer.index(datastoreValue));
}
} | java | private static void marshalField(PropertyMetadata propertyMetadata, Object target,
BaseEntity.Builder<?, ?> entityBuilder) {
Object fieldValue = IntrospectionUtils.getFieldValue(propertyMetadata, target);
if (fieldValue == null && propertyMetadata.isOptional()) {
return;
}
ValueBuilder<?, ?, ?> valueBuilder = propertyMetadata.getMapper().toDatastore(fieldValue);
// ListValues cannot have indexing turned off. Indexing is turned on by
// default, so we don't touch excludeFromIndexes for ListValues.
if (valueBuilder.getValueType() != ValueType.LIST) {
valueBuilder.setExcludeFromIndexes(!propertyMetadata.isIndexed());
}
Value<?> datastoreValue = valueBuilder.build();
entityBuilder.set(propertyMetadata.getMappedName(), datastoreValue);
Indexer indexer = propertyMetadata.getSecondaryIndexer();
if (indexer != null) {
entityBuilder.set(propertyMetadata.getSecondaryIndexName(), indexer.index(datastoreValue));
}
} | [
"private",
"static",
"void",
"marshalField",
"(",
"PropertyMetadata",
"propertyMetadata",
",",
"Object",
"target",
",",
"BaseEntity",
".",
"Builder",
"<",
"?",
",",
"?",
">",
"entityBuilder",
")",
"{",
"Object",
"fieldValue",
"=",
"IntrospectionUtils",
".",
"get... | Marshals the field with the given property metadata.
@param propertyMetadata
the metadata of the field to be marshaled.
@param target
the object in which the field is defined/accessible from
@param entityBuilder
the native entity on which the marshaled field should be set | [
"Marshals",
"the",
"field",
"with",
"the",
"given",
"property",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L440-L458 |
134,738 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalEmbeddedFields | private void marshalEmbeddedFields() {
for (EmbeddedMetadata embeddedMetadata : entityMetadata.getEmbeddedMetadataCollection()) {
if (embeddedMetadata.getStorageStrategy() == StorageStrategy.EXPLODED) {
marshalWithExplodedStrategy(embeddedMetadata, entity);
} else {
ValueBuilder<?, ?, ?> embeddedEntityBuilder = marshalWithImplodedStrategy(embeddedMetadata,
entity);
if (embeddedEntityBuilder != null) {
entityBuilder.set(embeddedMetadata.getMappedName(), embeddedEntityBuilder.build());
}
}
}
} | java | private void marshalEmbeddedFields() {
for (EmbeddedMetadata embeddedMetadata : entityMetadata.getEmbeddedMetadataCollection()) {
if (embeddedMetadata.getStorageStrategy() == StorageStrategy.EXPLODED) {
marshalWithExplodedStrategy(embeddedMetadata, entity);
} else {
ValueBuilder<?, ?, ?> embeddedEntityBuilder = marshalWithImplodedStrategy(embeddedMetadata,
entity);
if (embeddedEntityBuilder != null) {
entityBuilder.set(embeddedMetadata.getMappedName(), embeddedEntityBuilder.build());
}
}
}
} | [
"private",
"void",
"marshalEmbeddedFields",
"(",
")",
"{",
"for",
"(",
"EmbeddedMetadata",
"embeddedMetadata",
":",
"entityMetadata",
".",
"getEmbeddedMetadataCollection",
"(",
")",
")",
"{",
"if",
"(",
"embeddedMetadata",
".",
"getStorageStrategy",
"(",
")",
"==",
... | Marshals the embedded fields. | [
"Marshals",
"the",
"embedded",
"fields",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L474-L487 |
134,739 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalWithExplodedStrategy | private void marshalWithExplodedStrategy(EmbeddedMetadata embeddedMetadata, Object target) {
try {
Object embeddedObject = initializeEmbedded(embeddedMetadata, target);
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
marshalField(propertyMetadata, embeddedObject);
}
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
marshalWithExplodedStrategy(embeddedMetadata2, embeddedObject);
}
} catch (Throwable t) {
throw new EntityManagerException(t);
}
} | java | private void marshalWithExplodedStrategy(EmbeddedMetadata embeddedMetadata, Object target) {
try {
Object embeddedObject = initializeEmbedded(embeddedMetadata, target);
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
marshalField(propertyMetadata, embeddedObject);
}
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
marshalWithExplodedStrategy(embeddedMetadata2, embeddedObject);
}
} catch (Throwable t) {
throw new EntityManagerException(t);
}
} | [
"private",
"void",
"marshalWithExplodedStrategy",
"(",
"EmbeddedMetadata",
"embeddedMetadata",
",",
"Object",
"target",
")",
"{",
"try",
"{",
"Object",
"embeddedObject",
"=",
"initializeEmbedded",
"(",
"embeddedMetadata",
",",
"target",
")",
";",
"for",
"(",
"Proper... | Marshals an embedded field represented by the given metadata.
@param embeddedMetadata
the metadata of the embedded field
@param target
the target object to which the embedded object belongs | [
"Marshals",
"an",
"embedded",
"field",
"represented",
"by",
"the",
"given",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L497-L509 |
134,740 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalWithImplodedStrategy | private ValueBuilder<?, ?, ?> marshalWithImplodedStrategy(EmbeddedMetadata embeddedMetadata,
Object target) {
try {
Object embeddedObject = embeddedMetadata.getReadMethod().invoke(target);
if (embeddedObject == null) {
if (embeddedMetadata.isOptional()) {
return null;
}
NullValue.Builder nullValueBuilder = NullValue.newBuilder();
nullValueBuilder.setExcludeFromIndexes(!embeddedMetadata.isIndexed());
return nullValueBuilder;
}
FullEntity.Builder<IncompleteKey> embeddedEntityBuilder = FullEntity.newBuilder();
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
marshalField(propertyMetadata, embeddedObject, embeddedEntityBuilder);
}
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
ValueBuilder<?, ?, ?> embeddedEntityBuilder2 = marshalWithImplodedStrategy(
embeddedMetadata2, embeddedObject);
if (embeddedEntityBuilder2 != null) {
embeddedEntityBuilder.set(embeddedMetadata2.getMappedName(),
embeddedEntityBuilder2.build());
}
}
EntityValue.Builder valueBuilder = EntityValue.newBuilder(embeddedEntityBuilder.build());
valueBuilder.setExcludeFromIndexes(!embeddedMetadata.isIndexed());
return valueBuilder;
} catch (Throwable t) {
throw new EntityManagerException(t);
}
} | java | private ValueBuilder<?, ?, ?> marshalWithImplodedStrategy(EmbeddedMetadata embeddedMetadata,
Object target) {
try {
Object embeddedObject = embeddedMetadata.getReadMethod().invoke(target);
if (embeddedObject == null) {
if (embeddedMetadata.isOptional()) {
return null;
}
NullValue.Builder nullValueBuilder = NullValue.newBuilder();
nullValueBuilder.setExcludeFromIndexes(!embeddedMetadata.isIndexed());
return nullValueBuilder;
}
FullEntity.Builder<IncompleteKey> embeddedEntityBuilder = FullEntity.newBuilder();
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
marshalField(propertyMetadata, embeddedObject, embeddedEntityBuilder);
}
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
ValueBuilder<?, ?, ?> embeddedEntityBuilder2 = marshalWithImplodedStrategy(
embeddedMetadata2, embeddedObject);
if (embeddedEntityBuilder2 != null) {
embeddedEntityBuilder.set(embeddedMetadata2.getMappedName(),
embeddedEntityBuilder2.build());
}
}
EntityValue.Builder valueBuilder = EntityValue.newBuilder(embeddedEntityBuilder.build());
valueBuilder.setExcludeFromIndexes(!embeddedMetadata.isIndexed());
return valueBuilder;
} catch (Throwable t) {
throw new EntityManagerException(t);
}
} | [
"private",
"ValueBuilder",
"<",
"?",
",",
"?",
",",
"?",
">",
"marshalWithImplodedStrategy",
"(",
"EmbeddedMetadata",
"embeddedMetadata",
",",
"Object",
"target",
")",
"{",
"try",
"{",
"Object",
"embeddedObject",
"=",
"embeddedMetadata",
".",
"getReadMethod",
"(",... | Marshals the embedded field represented by the given metadata.
@param embeddedMetadata
the metadata of the embedded field.
@param target
the object in which the embedded field is defined/accessible from.
@return the ValueBuilder equivalent to embedded object | [
"Marshals",
"the",
"embedded",
"field",
"represented",
"by",
"the",
"given",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L520-L552 |
134,741 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalUpdatedTimestamp | private void marshalUpdatedTimestamp() {
PropertyMetadata updatedTimestampMetadata = entityMetadata.getUpdatedTimestampMetadata();
if (updatedTimestampMetadata != null) {
applyAutoTimestamp(updatedTimestampMetadata, System.currentTimeMillis());
}
} | java | private void marshalUpdatedTimestamp() {
PropertyMetadata updatedTimestampMetadata = entityMetadata.getUpdatedTimestampMetadata();
if (updatedTimestampMetadata != null) {
applyAutoTimestamp(updatedTimestampMetadata, System.currentTimeMillis());
}
} | [
"private",
"void",
"marshalUpdatedTimestamp",
"(",
")",
"{",
"PropertyMetadata",
"updatedTimestampMetadata",
"=",
"entityMetadata",
".",
"getUpdatedTimestampMetadata",
"(",
")",
";",
"if",
"(",
"updatedTimestampMetadata",
"!=",
"null",
")",
"{",
"applyAutoTimestamp",
"(... | Marshals the updated timestamp field. | [
"Marshals",
"the",
"updated",
"timestamp",
"field",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L575-L580 |
134,742 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalCreatedAndUpdatedTimestamp | private void marshalCreatedAndUpdatedTimestamp() {
PropertyMetadata createdTimestampMetadata = entityMetadata.getCreatedTimestampMetadata();
PropertyMetadata updatedTimestampMetadata = entityMetadata.getUpdatedTimestampMetadata();
long millis = System.currentTimeMillis();
if (createdTimestampMetadata != null) {
applyAutoTimestamp(createdTimestampMetadata, millis);
}
if (updatedTimestampMetadata != null) {
applyAutoTimestamp(updatedTimestampMetadata, millis);
}
} | java | private void marshalCreatedAndUpdatedTimestamp() {
PropertyMetadata createdTimestampMetadata = entityMetadata.getCreatedTimestampMetadata();
PropertyMetadata updatedTimestampMetadata = entityMetadata.getUpdatedTimestampMetadata();
long millis = System.currentTimeMillis();
if (createdTimestampMetadata != null) {
applyAutoTimestamp(createdTimestampMetadata, millis);
}
if (updatedTimestampMetadata != null) {
applyAutoTimestamp(updatedTimestampMetadata, millis);
}
} | [
"private",
"void",
"marshalCreatedAndUpdatedTimestamp",
"(",
")",
"{",
"PropertyMetadata",
"createdTimestampMetadata",
"=",
"entityMetadata",
".",
"getCreatedTimestampMetadata",
"(",
")",
";",
"PropertyMetadata",
"updatedTimestampMetadata",
"=",
"entityMetadata",
".",
"getUpd... | Marshals both created and updated timestamp fields. | [
"Marshals",
"both",
"created",
"and",
"updated",
"timestamp",
"fields",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L585-L595 |
134,743 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Marshaller.java | Marshaller.marshalVersionField | private void marshalVersionField() {
PropertyMetadata versionMetadata = entityMetadata.getVersionMetadata();
if (versionMetadata != null) {
long version = (long) IntrospectionUtils.getFieldValue(versionMetadata, entity);
ValueBuilder<?, ?, ?> valueBuilder = versionMetadata.getMapper().toDatastore(version + 1);
valueBuilder.setExcludeFromIndexes(!versionMetadata.isIndexed());
entityBuilder.set(versionMetadata.getMappedName(), valueBuilder.build());
}
} | java | private void marshalVersionField() {
PropertyMetadata versionMetadata = entityMetadata.getVersionMetadata();
if (versionMetadata != null) {
long version = (long) IntrospectionUtils.getFieldValue(versionMetadata, entity);
ValueBuilder<?, ?, ?> valueBuilder = versionMetadata.getMapper().toDatastore(version + 1);
valueBuilder.setExcludeFromIndexes(!versionMetadata.isIndexed());
entityBuilder.set(versionMetadata.getMappedName(), valueBuilder.build());
}
} | [
"private",
"void",
"marshalVersionField",
"(",
")",
"{",
"PropertyMetadata",
"versionMetadata",
"=",
"entityMetadata",
".",
"getVersionMetadata",
"(",
")",
";",
"if",
"(",
"versionMetadata",
"!=",
"null",
")",
"{",
"long",
"version",
"=",
"(",
"long",
")",
"In... | Marshals the version field, if it exists. The version will be set to one more than the previous
value. | [
"Marshals",
"the",
"version",
"field",
"if",
"it",
"exists",
".",
"The",
"version",
"will",
"be",
"set",
"to",
"one",
"more",
"than",
"the",
"previous",
"value",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Marshaller.java#L629-L637 |
134,744 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/mappers/ListMapper.java | ListMapper.initializeMapper | private void initializeMapper() {
if (itemClass == null) {
itemMapper = CatchAllMapper.getInstance();
} else {
try {
itemMapper = MapperFactory.getInstance().getMapper(itemClass);
} catch (NoSuitableMapperException exp) {
itemMapper = CatchAllMapper.getInstance();
}
}
} | java | private void initializeMapper() {
if (itemClass == null) {
itemMapper = CatchAllMapper.getInstance();
} else {
try {
itemMapper = MapperFactory.getInstance().getMapper(itemClass);
} catch (NoSuitableMapperException exp) {
itemMapper = CatchAllMapper.getInstance();
}
}
} | [
"private",
"void",
"initializeMapper",
"(",
")",
"{",
"if",
"(",
"itemClass",
"==",
"null",
")",
"{",
"itemMapper",
"=",
"CatchAllMapper",
".",
"getInstance",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"itemMapper",
"=",
"MapperFactory",
".",
"getInstanc... | Initializes the mapper for items in the List. | [
"Initializes",
"the",
"mapper",
"for",
"items",
"in",
"the",
"List",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/mappers/ListMapper.java#L87-L97 |
134,745 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/ConnectionParameters.java | ConnectionParameters.setJsonCredentialsFile | public void setJsonCredentialsFile(String jsonCredentialsPath) {
if (!Utility.isNullOrEmpty(jsonCredentialsPath)) {
setJsonCredentialsFile(new File(jsonCredentialsPath));
} else {
setJsonCredentialsFile((File) null);
}
} | java | public void setJsonCredentialsFile(String jsonCredentialsPath) {
if (!Utility.isNullOrEmpty(jsonCredentialsPath)) {
setJsonCredentialsFile(new File(jsonCredentialsPath));
} else {
setJsonCredentialsFile((File) null);
}
} | [
"public",
"void",
"setJsonCredentialsFile",
"(",
"String",
"jsonCredentialsPath",
")",
"{",
"if",
"(",
"!",
"Utility",
".",
"isNullOrEmpty",
"(",
"jsonCredentialsPath",
")",
")",
"{",
"setJsonCredentialsFile",
"(",
"new",
"File",
"(",
"jsonCredentialsPath",
")",
"... | Sets the JSON credentials path.
@param jsonCredentialsPath
the JSON credentials path. | [
"Sets",
"the",
"JSON",
"credentials",
"path",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/ConnectionParameters.java#L205-L211 |
134,746 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/mappers/MapMapper.java | MapMapper.initializeMapper | private void initializeMapper() {
if (valueClass == null) {
valueMapper = CatchAllMapper.getInstance();
} else {
try {
valueMapper = MapperFactory.getInstance().getMapper(valueClass);
} catch (NoSuitableMapperException exp) {
valueMapper = CatchAllMapper.getInstance();
}
}
} | java | private void initializeMapper() {
if (valueClass == null) {
valueMapper = CatchAllMapper.getInstance();
} else {
try {
valueMapper = MapperFactory.getInstance().getMapper(valueClass);
} catch (NoSuitableMapperException exp) {
valueMapper = CatchAllMapper.getInstance();
}
}
} | [
"private",
"void",
"initializeMapper",
"(",
")",
"{",
"if",
"(",
"valueClass",
"==",
"null",
")",
"{",
"valueMapper",
"=",
"CatchAllMapper",
".",
"getInstance",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"valueMapper",
"=",
"MapperFactory",
".",
"getInst... | Initializes the mapper for values in the Map. | [
"Initializes",
"the",
"mapper",
"for",
"values",
"in",
"the",
"Map",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/mappers/MapMapper.java#L96-L107 |
134,747 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/InternalListenerIntrospector.java | InternalListenerIntrospector.introspect | public static InternalListenerMetadata introspect(Class<?> listenerClass) {
InternalListenerMetadata cachedMetadata = cache.get(listenerClass);
if (cachedMetadata != null) {
return cachedMetadata;
}
synchronized (listenerClass) {
cachedMetadata = cache.get(listenerClass);
if (cachedMetadata != null) {
return cachedMetadata;
}
InternalListenerIntrospector introspector = new InternalListenerIntrospector(listenerClass);
introspector.introspect();
cache.put(listenerClass, introspector.metadata);
return introspector.metadata;
}
} | java | public static InternalListenerMetadata introspect(Class<?> listenerClass) {
InternalListenerMetadata cachedMetadata = cache.get(listenerClass);
if (cachedMetadata != null) {
return cachedMetadata;
}
synchronized (listenerClass) {
cachedMetadata = cache.get(listenerClass);
if (cachedMetadata != null) {
return cachedMetadata;
}
InternalListenerIntrospector introspector = new InternalListenerIntrospector(listenerClass);
introspector.introspect();
cache.put(listenerClass, introspector.metadata);
return introspector.metadata;
}
} | [
"public",
"static",
"InternalListenerMetadata",
"introspect",
"(",
"Class",
"<",
"?",
">",
"listenerClass",
")",
"{",
"InternalListenerMetadata",
"cachedMetadata",
"=",
"cache",
".",
"get",
"(",
"listenerClass",
")",
";",
"if",
"(",
"cachedMetadata",
"!=",
"null",... | Introspects the given class for any defined listeners and returns the metadata.
@param listenerClass
the entity listener class
@return the entity listener metadata | [
"Introspects",
"the",
"given",
"class",
"for",
"any",
"defined",
"listeners",
"and",
"returns",
"the",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/InternalListenerIntrospector.java#L64-L79 |
134,748 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/InternalListenerIntrospector.java | InternalListenerIntrospector.processMethods | private void processMethods() {
Method[] methods = listenerClass.getDeclaredMethods();
for (Method method : methods) {
for (CallbackType callbackType : CallbackType.values()) {
if (method.isAnnotationPresent(callbackType.getAnnotationClass())) {
validateMethod(method, callbackType);
metadata.putListener(callbackType, method);
}
}
}
} | java | private void processMethods() {
Method[] methods = listenerClass.getDeclaredMethods();
for (Method method : methods) {
for (CallbackType callbackType : CallbackType.values()) {
if (method.isAnnotationPresent(callbackType.getAnnotationClass())) {
validateMethod(method, callbackType);
metadata.putListener(callbackType, method);
}
}
}
} | [
"private",
"void",
"processMethods",
"(",
")",
"{",
"Method",
"[",
"]",
"methods",
"=",
"listenerClass",
".",
"getDeclaredMethods",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"methods",
")",
"{",
"for",
"(",
"CallbackType",
"callbackType",
":",
"C... | Processes the methods in the listener class and updates the metadata for any valid methods
found. | [
"Processes",
"the",
"methods",
"in",
"the",
"listener",
"class",
"and",
"updates",
"the",
"metadata",
"for",
"any",
"valid",
"methods",
"found",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/InternalListenerIntrospector.java#L93-L103 |
134,749 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/InternalListenerIntrospector.java | InternalListenerIntrospector.validateMethod | private void validateMethod(Method method, CallbackType callbackType) {
int modifiers = method.getModifiers();
if (!Modifier.isPublic(modifiers)) {
String message = String.format("Method %s in class %s must be public", method.getName(),
method.getDeclaringClass().getName());
throw new EntityManagerException(message);
}
if (Modifier.isStatic(modifiers)) {
String message = String.format("Method %s in class %s must not be static", method.getName(),
method.getDeclaringClass().getName());
throw new EntityManagerException(message);
}
if (Modifier.isAbstract(modifiers)) {
String message = String.format("Method %s in class %s must not be abstract", method.getName(),
method.getDeclaringClass().getName());
throw new EntityManagerException(message);
}
Class<?>[] parameters = method.getParameterTypes();
if (parameters.length != 0) {
String pattern = "Method %s in class %s is not a valid %s callback method. Method must not "
+ "have any parameters. ";
String message = String.format(pattern, method.getName(),
method.getDeclaringClass().getName(), callbackType);
throw new EntityManagerException(message);
}
if (method.getReturnType() != void.class) {
String message = String.format("Method %s in class %s must have a return type of %s",
method.getName(), method.getDeclaringClass().getName(), void.class.getName());
throw new EntityManagerException(message);
}
} | java | private void validateMethod(Method method, CallbackType callbackType) {
int modifiers = method.getModifiers();
if (!Modifier.isPublic(modifiers)) {
String message = String.format("Method %s in class %s must be public", method.getName(),
method.getDeclaringClass().getName());
throw new EntityManagerException(message);
}
if (Modifier.isStatic(modifiers)) {
String message = String.format("Method %s in class %s must not be static", method.getName(),
method.getDeclaringClass().getName());
throw new EntityManagerException(message);
}
if (Modifier.isAbstract(modifiers)) {
String message = String.format("Method %s in class %s must not be abstract", method.getName(),
method.getDeclaringClass().getName());
throw new EntityManagerException(message);
}
Class<?>[] parameters = method.getParameterTypes();
if (parameters.length != 0) {
String pattern = "Method %s in class %s is not a valid %s callback method. Method must not "
+ "have any parameters. ";
String message = String.format(pattern, method.getName(),
method.getDeclaringClass().getName(), callbackType);
throw new EntityManagerException(message);
}
if (method.getReturnType() != void.class) {
String message = String.format("Method %s in class %s must have a return type of %s",
method.getName(), method.getDeclaringClass().getName(), void.class.getName());
throw new EntityManagerException(message);
}
} | [
"private",
"void",
"validateMethod",
"(",
"Method",
"method",
",",
"CallbackType",
"callbackType",
")",
"{",
"int",
"modifiers",
"=",
"method",
".",
"getModifiers",
"(",
")",
";",
"if",
"(",
"!",
"Modifier",
".",
"isPublic",
"(",
"modifiers",
")",
")",
"{"... | Validates the given method to ensure if it is a valid callback method for the given event type.
@param method
the method to validate
@param callbackType
the callback type | [
"Validates",
"the",
"given",
"method",
"to",
"ensure",
"if",
"it",
"is",
"a",
"valid",
"callback",
"method",
"for",
"the",
"given",
"event",
"type",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/InternalListenerIntrospector.java#L113-L143 |
134,750 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.insert | public <E> E insert(E entity) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_INSERT, entity);
FullEntity<?> nativeEntity = (FullEntity<?>) Marshaller.marshal(entityManager, entity,
Intent.INSERT);
Entity insertedNativeEntity = nativeWriter.add(nativeEntity);
@SuppressWarnings("unchecked")
E insertedEntity = (E) Unmarshaller.unmarshal(insertedNativeEntity, entity.getClass());
entityManager.executeEntityListeners(CallbackType.POST_INSERT, insertedEntity);
return insertedEntity;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | public <E> E insert(E entity) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_INSERT, entity);
FullEntity<?> nativeEntity = (FullEntity<?>) Marshaller.marshal(entityManager, entity,
Intent.INSERT);
Entity insertedNativeEntity = nativeWriter.add(nativeEntity);
@SuppressWarnings("unchecked")
E insertedEntity = (E) Unmarshaller.unmarshal(insertedNativeEntity, entity.getClass());
entityManager.executeEntityListeners(CallbackType.POST_INSERT, insertedEntity);
return insertedEntity;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"public",
"<",
"E",
">",
"E",
"insert",
"(",
"E",
"entity",
")",
"{",
"try",
"{",
"entityManager",
".",
"executeEntityListeners",
"(",
"CallbackType",
".",
"PRE_INSERT",
",",
"entity",
")",
";",
"FullEntity",
"<",
"?",
">",
"nativeEntity",
"=",
"(",
"Ful... | Inserts the given entity into the Cloud Datastore.
@param entity
the entity to insert
@return the inserted entity. The inserted entity will not be same as the passed in entity. For
example, the inserted entity may contain any generated ID, key, parent key, etc.
@throws EntityManagerException
if any error occurs while inserting. | [
"Inserts",
"the",
"given",
"entity",
"into",
"the",
"Cloud",
"Datastore",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L110-L123 |
134,751 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.insert | @SuppressWarnings("unchecked")
public <E> List<E> insert(List<E> entities) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
try {
entityManager.executeEntityListeners(CallbackType.PRE_INSERT, entities);
FullEntity<?>[] nativeEntities = toNativeFullEntities(entities, entityManager, Intent.INSERT);
Class<?> entityClass = entities.get(0).getClass();
List<Entity> insertedNativeEntities = nativeWriter.add(nativeEntities);
List<E> insertedEntities = (List<E>) toEntities(entityClass, insertedNativeEntities);
entityManager.executeEntityListeners(CallbackType.POST_INSERT, insertedEntities);
return insertedEntities;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | @SuppressWarnings("unchecked")
public <E> List<E> insert(List<E> entities) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
try {
entityManager.executeEntityListeners(CallbackType.PRE_INSERT, entities);
FullEntity<?>[] nativeEntities = toNativeFullEntities(entities, entityManager, Intent.INSERT);
Class<?> entityClass = entities.get(0).getClass();
List<Entity> insertedNativeEntities = nativeWriter.add(nativeEntities);
List<E> insertedEntities = (List<E>) toEntities(entityClass, insertedNativeEntities);
entityManager.executeEntityListeners(CallbackType.POST_INSERT, insertedEntities);
return insertedEntities;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"E",
">",
"List",
"<",
"E",
">",
"insert",
"(",
"List",
"<",
"E",
">",
"entities",
")",
"{",
"if",
"(",
"entities",
"==",
"null",
"||",
"entities",
".",
"isEmpty",
"(",
")",
")",
"{... | Inserts the given list of entities into the Cloud Datastore.
@param entities
the entities to insert.
@return the inserted entities. The inserted entities will not be same as the passed in
entities. For example, the inserted entities may contain generated ID, key, parent key,
etc.
@throws EntityManagerException
if any error occurs while inserting. | [
"Inserts",
"the",
"given",
"list",
"of",
"entities",
"into",
"the",
"Cloud",
"Datastore",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L136-L152 |
134,752 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.update | @SuppressWarnings("unchecked")
public <E> E update(E entity) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entity);
Intent intent = (nativeWriter instanceof Batch) ? Intent.BATCH_UPDATE : Intent.UPDATE;
Entity nativeEntity = (Entity) Marshaller.marshal(entityManager, entity, intent);
nativeWriter.update(nativeEntity);
E updatedEntity = (E) Unmarshaller.unmarshal(nativeEntity, entity.getClass());
entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntity);
return updatedEntity;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | @SuppressWarnings("unchecked")
public <E> E update(E entity) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entity);
Intent intent = (nativeWriter instanceof Batch) ? Intent.BATCH_UPDATE : Intent.UPDATE;
Entity nativeEntity = (Entity) Marshaller.marshal(entityManager, entity, intent);
nativeWriter.update(nativeEntity);
E updatedEntity = (E) Unmarshaller.unmarshal(nativeEntity, entity.getClass());
entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntity);
return updatedEntity;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"E",
">",
"E",
"update",
"(",
"E",
"entity",
")",
"{",
"try",
"{",
"entityManager",
".",
"executeEntityListeners",
"(",
"CallbackType",
".",
"PRE_UPDATE",
",",
"entity",
")",
";",
"Intent",
... | Updates the given entity in the Cloud Datastore. The passed in Entity must have its ID set for
the update to work.
@param entity
the entity to update
@return the updated entity.
@throws EntityManagerException
if any error occurs while updating. | [
"Updates",
"the",
"given",
"entity",
"in",
"the",
"Cloud",
"Datastore",
".",
"The",
"passed",
"in",
"Entity",
"must",
"have",
"its",
"ID",
"set",
"for",
"the",
"update",
"to",
"work",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L164-L178 |
134,753 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.update | @SuppressWarnings("unchecked")
public <E> List<E> update(List<E> entities) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
try {
Class<E> entityClass = (Class<E>) entities.get(0).getClass();
entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entities);
Intent intent = (nativeWriter instanceof Batch) ? Intent.BATCH_UPDATE : Intent.UPDATE;
Entity[] nativeEntities = toNativeEntities(entities, entityManager, intent);
nativeWriter.update(nativeEntities);
List<E> updatedEntities = toEntities(entityClass, nativeEntities);
entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntities);
return updatedEntities;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | @SuppressWarnings("unchecked")
public <E> List<E> update(List<E> entities) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
try {
Class<E> entityClass = (Class<E>) entities.get(0).getClass();
entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entities);
Intent intent = (nativeWriter instanceof Batch) ? Intent.BATCH_UPDATE : Intent.UPDATE;
Entity[] nativeEntities = toNativeEntities(entities, entityManager, intent);
nativeWriter.update(nativeEntities);
List<E> updatedEntities = toEntities(entityClass, nativeEntities);
entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntities);
return updatedEntities;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"E",
">",
"List",
"<",
"E",
">",
"update",
"(",
"List",
"<",
"E",
">",
"entities",
")",
"{",
"if",
"(",
"entities",
"==",
"null",
"||",
"entities",
".",
"isEmpty",
"(",
")",
")",
"{... | Updates the given list of entities in the Cloud Datastore.
@param entities
the entities to update. The passed in entities must have their ID set for the update
to work.
@return the updated entities
@throws EntityManagerException
if any error occurs while inserting. | [
"Updates",
"the",
"given",
"list",
"of",
"entities",
"in",
"the",
"Cloud",
"Datastore",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L190-L207 |
134,754 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.updateWithOptimisticLock | public <E> E updateWithOptimisticLock(E entity) {
PropertyMetadata versionMetadata = EntityIntrospector.getVersionMetadata(entity);
if (versionMetadata == null) {
return update(entity);
} else {
return updateWithOptimisticLockingInternal(entity, versionMetadata);
}
} | java | public <E> E updateWithOptimisticLock(E entity) {
PropertyMetadata versionMetadata = EntityIntrospector.getVersionMetadata(entity);
if (versionMetadata == null) {
return update(entity);
} else {
return updateWithOptimisticLockingInternal(entity, versionMetadata);
}
} | [
"public",
"<",
"E",
">",
"E",
"updateWithOptimisticLock",
"(",
"E",
"entity",
")",
"{",
"PropertyMetadata",
"versionMetadata",
"=",
"EntityIntrospector",
".",
"getVersionMetadata",
"(",
"entity",
")",
";",
"if",
"(",
"versionMetadata",
"==",
"null",
")",
"{",
... | Updates the given entity with optimistic locking, if the entity is set up to support optimistic
locking. Otherwise, a normal update is performed.
@param entity
the entity to update
@return the updated entity which may be different than the given entity. | [
"Updates",
"the",
"given",
"entity",
"with",
"optimistic",
"locking",
"if",
"the",
"entity",
"is",
"set",
"up",
"to",
"support",
"optimistic",
"locking",
".",
"Otherwise",
"a",
"normal",
"update",
"is",
"performed",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L217-L225 |
134,755 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.updateWithOptimisticLock | public <E> List<E> updateWithOptimisticLock(List<E> entities) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
Class<?> entityClass = entities.get(0).getClass();
PropertyMetadata versionMetadata = EntityIntrospector.getVersionMetadata(entityClass);
if (versionMetadata == null) {
return update(entities);
} else {
return updateWithOptimisticLockInternal(entities, versionMetadata);
}
} | java | public <E> List<E> updateWithOptimisticLock(List<E> entities) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
Class<?> entityClass = entities.get(0).getClass();
PropertyMetadata versionMetadata = EntityIntrospector.getVersionMetadata(entityClass);
if (versionMetadata == null) {
return update(entities);
} else {
return updateWithOptimisticLockInternal(entities, versionMetadata);
}
} | [
"public",
"<",
"E",
">",
"List",
"<",
"E",
">",
"updateWithOptimisticLock",
"(",
"List",
"<",
"E",
">",
"entities",
")",
"{",
"if",
"(",
"entities",
"==",
"null",
"||",
"entities",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"new",
"ArrayList",
"<>... | Updates the given list of entities using optimistic locking feature, if the entities are set up
to support optimistic locking. Otherwise, a normal update is performed.
@param entities
the entities to update
@return the updated entities | [
"Updates",
"the",
"given",
"list",
"of",
"entities",
"using",
"optimistic",
"locking",
"feature",
"if",
"the",
"entities",
"are",
"set",
"up",
"to",
"support",
"optimistic",
"locking",
".",
"Otherwise",
"a",
"normal",
"update",
"is",
"performed",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L235-L246 |
134,756 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.updateWithOptimisticLockingInternal | @SuppressWarnings("unchecked")
protected <E> E updateWithOptimisticLockingInternal(E entity, PropertyMetadata versionMetadata) {
Transaction transaction = null;
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entity);
Entity nativeEntity = (Entity) Marshaller.marshal(entityManager, entity, Intent.UPDATE);
transaction = datastore.newTransaction();
Entity storedNativeEntity = transaction.get(nativeEntity.getKey());
if (storedNativeEntity == null) {
throw new OptimisticLockException(
String.format("Entity does not exist: %s", nativeEntity.getKey()));
}
String versionPropertyName = versionMetadata.getMappedName();
long version = nativeEntity.getLong(versionPropertyName) - 1;
long storedVersion = storedNativeEntity.getLong(versionPropertyName);
if (version != storedVersion) {
throw new OptimisticLockException(
String.format("Expecting version %d, but found %d", version, storedVersion));
}
transaction.update(nativeEntity);
transaction.commit();
E updatedEntity = (E) Unmarshaller.unmarshal(nativeEntity, entity.getClass());
entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntity);
return updatedEntity;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
} finally {
rollbackIfActive(transaction);
}
} | java | @SuppressWarnings("unchecked")
protected <E> E updateWithOptimisticLockingInternal(E entity, PropertyMetadata versionMetadata) {
Transaction transaction = null;
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entity);
Entity nativeEntity = (Entity) Marshaller.marshal(entityManager, entity, Intent.UPDATE);
transaction = datastore.newTransaction();
Entity storedNativeEntity = transaction.get(nativeEntity.getKey());
if (storedNativeEntity == null) {
throw new OptimisticLockException(
String.format("Entity does not exist: %s", nativeEntity.getKey()));
}
String versionPropertyName = versionMetadata.getMappedName();
long version = nativeEntity.getLong(versionPropertyName) - 1;
long storedVersion = storedNativeEntity.getLong(versionPropertyName);
if (version != storedVersion) {
throw new OptimisticLockException(
String.format("Expecting version %d, but found %d", version, storedVersion));
}
transaction.update(nativeEntity);
transaction.commit();
E updatedEntity = (E) Unmarshaller.unmarshal(nativeEntity, entity.getClass());
entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntity);
return updatedEntity;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
} finally {
rollbackIfActive(transaction);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"<",
"E",
">",
"E",
"updateWithOptimisticLockingInternal",
"(",
"E",
"entity",
",",
"PropertyMetadata",
"versionMetadata",
")",
"{",
"Transaction",
"transaction",
"=",
"null",
";",
"try",
"{",
"entit... | Worker method for updating the given entity with optimistic locking.
@param entity
the entity to update
@param versionMetadata
the metadata for optimistic locking
@return the updated entity | [
"Worker",
"method",
"for",
"updating",
"the",
"given",
"entity",
"with",
"optimistic",
"locking",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L257-L286 |
134,757 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.updateWithOptimisticLockInternal | @SuppressWarnings("unchecked")
protected <E> List<E> updateWithOptimisticLockInternal(List<E> entities,
PropertyMetadata versionMetadata) {
Transaction transaction = null;
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entities);
Entity[] nativeEntities = toNativeEntities(entities, entityManager, Intent.UPDATE);
// The above native entities already have the version incremented by
// the marshalling process
Key[] nativeKeys = new Key[nativeEntities.length];
for (int i = 0; i < nativeEntities.length; i++) {
nativeKeys[i] = nativeEntities[i].getKey();
}
transaction = datastore.newTransaction();
List<Entity> storedNativeEntities = transaction.fetch(nativeKeys);
String versionPropertyName = versionMetadata.getMappedName();
for (int i = 0; i < nativeEntities.length; i++) {
long version = nativeEntities[i].getLong(versionPropertyName) - 1;
Entity storedNativeEntity = storedNativeEntities.get(i);
if (storedNativeEntity == null) {
throw new OptimisticLockException(
String.format("Entity does not exist: %s", nativeKeys[i]));
}
long storedVersion = storedNativeEntities.get(i).getLong(versionPropertyName);
if (version != storedVersion) {
throw new OptimisticLockException(
String.format("Expecting version %d, but found %d", version, storedVersion));
}
}
transaction.update(nativeEntities);
transaction.commit();
List<E> updatedEntities = (List<E>) toEntities(entities.get(0).getClass(), nativeEntities);
entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntities);
return updatedEntities;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
} finally {
rollbackIfActive(transaction);
}
} | java | @SuppressWarnings("unchecked")
protected <E> List<E> updateWithOptimisticLockInternal(List<E> entities,
PropertyMetadata versionMetadata) {
Transaction transaction = null;
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entities);
Entity[] nativeEntities = toNativeEntities(entities, entityManager, Intent.UPDATE);
// The above native entities already have the version incremented by
// the marshalling process
Key[] nativeKeys = new Key[nativeEntities.length];
for (int i = 0; i < nativeEntities.length; i++) {
nativeKeys[i] = nativeEntities[i].getKey();
}
transaction = datastore.newTransaction();
List<Entity> storedNativeEntities = transaction.fetch(nativeKeys);
String versionPropertyName = versionMetadata.getMappedName();
for (int i = 0; i < nativeEntities.length; i++) {
long version = nativeEntities[i].getLong(versionPropertyName) - 1;
Entity storedNativeEntity = storedNativeEntities.get(i);
if (storedNativeEntity == null) {
throw new OptimisticLockException(
String.format("Entity does not exist: %s", nativeKeys[i]));
}
long storedVersion = storedNativeEntities.get(i).getLong(versionPropertyName);
if (version != storedVersion) {
throw new OptimisticLockException(
String.format("Expecting version %d, but found %d", version, storedVersion));
}
}
transaction.update(nativeEntities);
transaction.commit();
List<E> updatedEntities = (List<E>) toEntities(entities.get(0).getClass(), nativeEntities);
entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntities);
return updatedEntities;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
} finally {
rollbackIfActive(transaction);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"<",
"E",
">",
"List",
"<",
"E",
">",
"updateWithOptimisticLockInternal",
"(",
"List",
"<",
"E",
">",
"entities",
",",
"PropertyMetadata",
"versionMetadata",
")",
"{",
"Transaction",
"transaction",
... | Internal worker method for updating the entities using optimistic locking.
@param entities
the entities to update
@param versionMetadata
the metadata of the version property
@return the updated entities | [
"Internal",
"worker",
"method",
"for",
"updating",
"the",
"entities",
"using",
"optimistic",
"locking",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L297-L339 |
134,758 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.upsert | public <E> E upsert(E entity) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPSERT, entity);
FullEntity<?> nativeEntity = (FullEntity<?>) Marshaller.marshal(entityManager, entity,
Intent.UPSERT);
Entity upsertedNativeEntity = nativeWriter.put(nativeEntity);
@SuppressWarnings("unchecked")
E upsertedEntity = (E) Unmarshaller.unmarshal(upsertedNativeEntity, entity.getClass());
entityManager.executeEntityListeners(CallbackType.POST_UPSERT, upsertedEntity);
return upsertedEntity;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | public <E> E upsert(E entity) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPSERT, entity);
FullEntity<?> nativeEntity = (FullEntity<?>) Marshaller.marshal(entityManager, entity,
Intent.UPSERT);
Entity upsertedNativeEntity = nativeWriter.put(nativeEntity);
@SuppressWarnings("unchecked")
E upsertedEntity = (E) Unmarshaller.unmarshal(upsertedNativeEntity, entity.getClass());
entityManager.executeEntityListeners(CallbackType.POST_UPSERT, upsertedEntity);
return upsertedEntity;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"public",
"<",
"E",
">",
"E",
"upsert",
"(",
"E",
"entity",
")",
"{",
"try",
"{",
"entityManager",
".",
"executeEntityListeners",
"(",
"CallbackType",
".",
"PRE_UPSERT",
",",
"entity",
")",
";",
"FullEntity",
"<",
"?",
">",
"nativeEntity",
"=",
"(",
"Ful... | Updates or inserts the given entity in the Cloud Datastore. If the entity does not have an ID,
it may be generated.
@param entity
the entity to update or insert
@return the updated/inserted entity.
@throws EntityManagerException
if any error occurs while saving. | [
"Updates",
"or",
"inserts",
"the",
"given",
"entity",
"in",
"the",
"Cloud",
"Datastore",
".",
"If",
"the",
"entity",
"does",
"not",
"have",
"an",
"ID",
"it",
"may",
"be",
"generated",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L351-L364 |
134,759 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.upsert | @SuppressWarnings("unchecked")
public <E> List<E> upsert(List<E> entities) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPSERT, entities);
FullEntity<?>[] nativeEntities = toNativeFullEntities(entities, entityManager, Intent.UPSERT);
Class<?> entityClass = entities.get(0).getClass();
List<Entity> upsertedNativeEntities = nativeWriter.put(nativeEntities);
List<E> upsertedEntities = (List<E>) toEntities(entityClass, upsertedNativeEntities);
entityManager.executeEntityListeners(CallbackType.POST_UPSERT, upsertedEntities);
return upsertedEntities;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | @SuppressWarnings("unchecked")
public <E> List<E> upsert(List<E> entities) {
if (entities == null || entities.isEmpty()) {
return new ArrayList<>();
}
try {
entityManager.executeEntityListeners(CallbackType.PRE_UPSERT, entities);
FullEntity<?>[] nativeEntities = toNativeFullEntities(entities, entityManager, Intent.UPSERT);
Class<?> entityClass = entities.get(0).getClass();
List<Entity> upsertedNativeEntities = nativeWriter.put(nativeEntities);
List<E> upsertedEntities = (List<E>) toEntities(entityClass, upsertedNativeEntities);
entityManager.executeEntityListeners(CallbackType.POST_UPSERT, upsertedEntities);
return upsertedEntities;
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"E",
">",
"List",
"<",
"E",
">",
"upsert",
"(",
"List",
"<",
"E",
">",
"entities",
")",
"{",
"if",
"(",
"entities",
"==",
"null",
"||",
"entities",
".",
"isEmpty",
"(",
")",
")",
"{... | Updates or inserts the given list of entities in the Cloud Datastore. If the entities do not
have a valid ID, IDs may be generated.
@param entities
the entities to update/or insert.
@return the updated or inserted entities
@throws EntityManagerException
if any error occurs while saving. | [
"Updates",
"or",
"inserts",
"the",
"given",
"list",
"of",
"entities",
"in",
"the",
"Cloud",
"Datastore",
".",
"If",
"the",
"entities",
"do",
"not",
"have",
"a",
"valid",
"ID",
"IDs",
"may",
"be",
"generated",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L376-L392 |
134,760 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.delete | public void delete(Object entity) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_DELETE, entity);
Key nativeKey = Marshaller.marshalKey(entityManager, entity);
nativeWriter.delete(nativeKey);
entityManager.executeEntityListeners(CallbackType.POST_DELETE, entity);
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | public void delete(Object entity) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_DELETE, entity);
Key nativeKey = Marshaller.marshalKey(entityManager, entity);
nativeWriter.delete(nativeKey);
entityManager.executeEntityListeners(CallbackType.POST_DELETE, entity);
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"public",
"void",
"delete",
"(",
"Object",
"entity",
")",
"{",
"try",
"{",
"entityManager",
".",
"executeEntityListeners",
"(",
"CallbackType",
".",
"PRE_DELETE",
",",
"entity",
")",
";",
"Key",
"nativeKey",
"=",
"Marshaller",
".",
"marshalKey",
"(",
"entityMa... | Deletes the given entity from the Cloud Datastore.
@param entity
the entity to delete. The entity must have it ID set for the deletion to succeed.
@throws EntityManagerException
if any error occurs while deleting. | [
"Deletes",
"the",
"given",
"entity",
"from",
"the",
"Cloud",
"Datastore",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L402-L411 |
134,761 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.delete | public void delete(List<?> entities) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_DELETE, entities);
Key[] nativeKeys = new Key[entities.size()];
for (int i = 0; i < entities.size(); i++) {
nativeKeys[i] = Marshaller.marshalKey(entityManager, entities.get(i));
}
nativeWriter.delete(nativeKeys);
entityManager.executeEntityListeners(CallbackType.POST_DELETE, entities);
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | public void delete(List<?> entities) {
try {
entityManager.executeEntityListeners(CallbackType.PRE_DELETE, entities);
Key[] nativeKeys = new Key[entities.size()];
for (int i = 0; i < entities.size(); i++) {
nativeKeys[i] = Marshaller.marshalKey(entityManager, entities.get(i));
}
nativeWriter.delete(nativeKeys);
entityManager.executeEntityListeners(CallbackType.POST_DELETE, entities);
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"public",
"void",
"delete",
"(",
"List",
"<",
"?",
">",
"entities",
")",
"{",
"try",
"{",
"entityManager",
".",
"executeEntityListeners",
"(",
"CallbackType",
".",
"PRE_DELETE",
",",
"entities",
")",
";",
"Key",
"[",
"]",
"nativeKeys",
"=",
"new",
"Key",
... | Deletes the given entities from the Cloud Datastore.
@param entities
the entities to delete. The entities must have it ID set for the deletion to succeed.
@throws EntityManagerException
if any error occurs while deleting. | [
"Deletes",
"the",
"given",
"entities",
"from",
"the",
"Cloud",
"Datastore",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L421-L433 |
134,762 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.delete | public <E> void delete(Class<E> entityClass, DatastoreKey parentKey, long id) {
try {
EntityMetadata entityMetadata = EntityIntrospector.introspect(entityClass);
Key nativeKey = Key.newBuilder(parentKey.nativeKey(), entityMetadata.getKind(), id).build();
nativeWriter.delete(nativeKey);
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | public <E> void delete(Class<E> entityClass, DatastoreKey parentKey, long id) {
try {
EntityMetadata entityMetadata = EntityIntrospector.introspect(entityClass);
Key nativeKey = Key.newBuilder(parentKey.nativeKey(), entityMetadata.getKind(), id).build();
nativeWriter.delete(nativeKey);
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"public",
"<",
"E",
">",
"void",
"delete",
"(",
"Class",
"<",
"E",
">",
"entityClass",
",",
"DatastoreKey",
"parentKey",
",",
"long",
"id",
")",
"{",
"try",
"{",
"EntityMetadata",
"entityMetadata",
"=",
"EntityIntrospector",
".",
"introspect",
"(",
"entityCl... | Deletes the entity with the given ID and parent key.
@param entityClass
the entity class.
@param parentKey
the parent key
@param id
the ID of the entity.
@throws EntityManagerException
if any error occurs while inserting. | [
"Deletes",
"the",
"entity",
"with",
"the",
"given",
"ID",
"and",
"parent",
"key",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L491-L499 |
134,763 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.deleteByKey | public void deleteByKey(DatastoreKey key) {
try {
nativeWriter.delete(key.nativeKey());
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | public void deleteByKey(DatastoreKey key) {
try {
nativeWriter.delete(key.nativeKey());
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"public",
"void",
"deleteByKey",
"(",
"DatastoreKey",
"key",
")",
"{",
"try",
"{",
"nativeWriter",
".",
"delete",
"(",
"key",
".",
"nativeKey",
"(",
")",
")",
";",
"}",
"catch",
"(",
"DatastoreException",
"exp",
")",
"{",
"throw",
"DatastoreUtils",
".",
... | Deletes an entity given its key.
@param key
the entity's key
@throws EntityManagerException
if any error occurs while deleting. | [
"Deletes",
"an",
"entity",
"given",
"its",
"key",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L531-L537 |
134,764 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java | DefaultDatastoreWriter.deleteByKey | public void deleteByKey(List<DatastoreKey> keys) {
try {
Key[] nativeKeys = new Key[keys.size()];
for (int i = 0; i < keys.size(); i++) {
nativeKeys[i] = keys.get(i).nativeKey();
}
nativeWriter.delete(nativeKeys);
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | java | public void deleteByKey(List<DatastoreKey> keys) {
try {
Key[] nativeKeys = new Key[keys.size()];
for (int i = 0; i < keys.size(); i++) {
nativeKeys[i] = keys.get(i).nativeKey();
}
nativeWriter.delete(nativeKeys);
} catch (DatastoreException exp) {
throw DatastoreUtils.wrap(exp);
}
} | [
"public",
"void",
"deleteByKey",
"(",
"List",
"<",
"DatastoreKey",
">",
"keys",
")",
"{",
"try",
"{",
"Key",
"[",
"]",
"nativeKeys",
"=",
"new",
"Key",
"[",
"keys",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<... | Deletes the entities having the given keys.
@param keys
the entities' keys
@throws EntityManagerException
if any error occurs while deleting. | [
"Deletes",
"the",
"entities",
"having",
"the",
"given",
"keys",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/DefaultDatastoreWriter.java#L547-L557 |
134,765 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/BaseQueryRequest.java | BaseQueryRequest.setNamedBindings | public void setNamedBindings(Map<String, Object> namedBindings) {
if (namedBindings == null) {
throw new IllegalArgumentException("namedBindings cannot be null");
}
this.namedBindings = namedBindings;
} | java | public void setNamedBindings(Map<String, Object> namedBindings) {
if (namedBindings == null) {
throw new IllegalArgumentException("namedBindings cannot be null");
}
this.namedBindings = namedBindings;
} | [
"public",
"void",
"setNamedBindings",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"namedBindings",
")",
"{",
"if",
"(",
"namedBindings",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"namedBindings cannot be null\"",
")",
";",
"}"... | Sets the named bindings that are needed for any named parameters in the GQL query.
@param namedBindings
the named bindings.
@throws NullPointerException
if the <code>namedBindings</code> argument is <code>null</code>. | [
"Sets",
"the",
"named",
"bindings",
"that",
"are",
"needed",
"for",
"any",
"named",
"parameters",
"in",
"the",
"GQL",
"query",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/BaseQueryRequest.java#L95-L100 |
134,766 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/BaseQueryRequest.java | BaseQueryRequest.addPositionalBindings | public void addPositionalBindings(Object first, Object... others) {
positionalBindings.add(first);
positionalBindings.addAll(Arrays.asList(others));
} | java | public void addPositionalBindings(Object first, Object... others) {
positionalBindings.add(first);
positionalBindings.addAll(Arrays.asList(others));
} | [
"public",
"void",
"addPositionalBindings",
"(",
"Object",
"first",
",",
"Object",
"...",
"others",
")",
"{",
"positionalBindings",
".",
"add",
"(",
"first",
")",
";",
"positionalBindings",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"others",
")",
")",... | Adds the positional bindings that are needed for any positional parameters in the GQL query.
@param first
the first positional binding
@param others
subsequent positional bindings, if any | [
"Adds",
"the",
"positional",
"bindings",
"that",
"are",
"needed",
"for",
"any",
"positional",
"parameters",
"in",
"the",
"GQL",
"query",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/BaseQueryRequest.java#L152-L155 |
134,767 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddedField.java | EmbeddedField.computeQualifiedName | private void computeQualifiedName() {
if (parent != null) {
qualifiedName = parent.qualifiedName + "." + field.getName();
} else {
qualifiedName = field.getName();
}
} | java | private void computeQualifiedName() {
if (parent != null) {
qualifiedName = parent.qualifiedName + "." + field.getName();
} else {
qualifiedName = field.getName();
}
} | [
"private",
"void",
"computeQualifiedName",
"(",
")",
"{",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"qualifiedName",
"=",
"parent",
".",
"qualifiedName",
"+",
"\".\"",
"+",
"field",
".",
"getName",
"(",
")",
";",
"}",
"else",
"{",
"qualifiedName",
"="... | Computes and sets the qualified name of this field. | [
"Computes",
"and",
"sets",
"the",
"qualified",
"name",
"of",
"this",
"field",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddedField.java#L128-L134 |
134,768 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersMetadata.java | EntityListenersMetadata.put | public void put(CallbackType callbackType, CallbackMetadata callbackMetadata) {
if (callbacks == null) {
callbacks = new EnumMap<>(CallbackType.class);
}
List<CallbackMetadata> callbackMetadataList = callbacks.get(callbackType);
if (callbackMetadataList == null) {
callbackMetadataList = new ArrayList<>();
callbacks.put(callbackType, callbackMetadataList);
}
callbackMetadataList.add(callbackMetadata);
} | java | public void put(CallbackType callbackType, CallbackMetadata callbackMetadata) {
if (callbacks == null) {
callbacks = new EnumMap<>(CallbackType.class);
}
List<CallbackMetadata> callbackMetadataList = callbacks.get(callbackType);
if (callbackMetadataList == null) {
callbackMetadataList = new ArrayList<>();
callbacks.put(callbackType, callbackMetadataList);
}
callbackMetadataList.add(callbackMetadata);
} | [
"public",
"void",
"put",
"(",
"CallbackType",
"callbackType",
",",
"CallbackMetadata",
"callbackMetadata",
")",
"{",
"if",
"(",
"callbacks",
"==",
"null",
")",
"{",
"callbacks",
"=",
"new",
"EnumMap",
"<>",
"(",
"CallbackType",
".",
"class",
")",
";",
"}",
... | Adds the given CallbackEventMetadata.
@param callbackType
the callback type
@param callbackMetadata
the metadata of the callback | [
"Adds",
"the",
"given",
"CallbackEventMetadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersMetadata.java#L122-L132 |
134,769 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityListenersMetadata.java | EntityListenersMetadata.getCallbacks | public List<CallbackMetadata> getCallbacks(CallbackType callbackType) {
return callbacks == null ? null : callbacks.get(callbackType);
} | java | public List<CallbackMetadata> getCallbacks(CallbackType callbackType) {
return callbacks == null ? null : callbacks.get(callbackType);
} | [
"public",
"List",
"<",
"CallbackMetadata",
">",
"getCallbacks",
"(",
"CallbackType",
"callbackType",
")",
"{",
"return",
"callbacks",
"==",
"null",
"?",
"null",
":",
"callbacks",
".",
"get",
"(",
"callbackType",
")",
";",
"}"
] | Returns the callbacks for the given callback type.
@param callbackType
the callback type
@return the list of callbacks for the given callback type | [
"Returns",
"the",
"callbacks",
"for",
"the",
"given",
"callback",
"type",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityListenersMetadata.java#L141-L143 |
134,770 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/ConstructorIntrospector.java | ConstructorIntrospector.loadMetadata | private static ConstructorMetadata loadMetadata(Class<?> clazz) {
synchronized (clazz) {
ConstructorMetadata metadata = cache.get(clazz);
if (metadata == null) {
ConstructorIntrospector introspector = new ConstructorIntrospector(clazz);
introspector.process();
metadata = introspector.metadataBuilder.build();
cache.put(clazz, metadata);
}
return metadata;
}
} | java | private static ConstructorMetadata loadMetadata(Class<?> clazz) {
synchronized (clazz) {
ConstructorMetadata metadata = cache.get(clazz);
if (metadata == null) {
ConstructorIntrospector introspector = new ConstructorIntrospector(clazz);
introspector.process();
metadata = introspector.metadataBuilder.build();
cache.put(clazz, metadata);
}
return metadata;
}
} | [
"private",
"static",
"ConstructorMetadata",
"loadMetadata",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"synchronized",
"(",
"clazz",
")",
"{",
"ConstructorMetadata",
"metadata",
"=",
"cache",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"metadata",
... | Loads the metadata, if it does not already exist in the cache.
@param clazz
the class to introspect
@return the metadata | [
"Loads",
"the",
"metadata",
"if",
"it",
"does",
"not",
"already",
"exist",
"in",
"the",
"cache",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/ConstructorIntrospector.java#L101-L112 |
134,771 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/ConstructorIntrospector.java | ConstructorIntrospector.process | private void process() {
metadataBuilder = ConstructorMetadata.newBuilder().setClazz(clazz);
MethodHandle mh = IntrospectionUtils.findDefaultConstructor(clazz);
if (mh != null) {
metadataBuilder.setConstructionStrategy(ConstructorMetadata.ConstructionStrategy.CLASSIC)
.setConstructorMethodHandle(mh);
// We have everything we need for the classic pattern with a default
// constructor and accessor/mutator methods, more validations will
// follow.
return;
}
// Now we check for Builder pattern usage
mh = findNewBuilderMethod(clazz);
if (mh == null) {
final String pattern = "Class %s requires a public no-arg constructor or a public static "
+ "method that returns a corresponding Builder instance. The name of the static method "
+ "can either be %s or %s";
String error = String.format(pattern, clazz.getName(), METHOD_NAME_NEW_BUILDER,
METHOD_NAME_BUILDER);
throw new UnsupportedConstructionStrategyException(error);
}
Class<?> builderClass = mh.type().returnType();
metadataBuilder.setConstructionStrategy(ConstructorMetadata.ConstructionStrategy.BUILDER)
.setConstructorMethodHandle(mh).setBuilderClass(builderClass);
MethodHandle buildMethodHandle = IntrospectionUtils.findInstanceMethod(builderClass,
METHOD_NAME_BUILD, clazz);
if (buildMethodHandle == null) {
String pattern = "Class %s requires a public instance method, %s, with a return type of %s";
throw new EntityManagerException(
String.format(pattern, builderClass.getName(), METHOD_NAME_BUILD, clazz));
}
metadataBuilder.setBuildMethodHandle(buildMethodHandle);
} | java | private void process() {
metadataBuilder = ConstructorMetadata.newBuilder().setClazz(clazz);
MethodHandle mh = IntrospectionUtils.findDefaultConstructor(clazz);
if (mh != null) {
metadataBuilder.setConstructionStrategy(ConstructorMetadata.ConstructionStrategy.CLASSIC)
.setConstructorMethodHandle(mh);
// We have everything we need for the classic pattern with a default
// constructor and accessor/mutator methods, more validations will
// follow.
return;
}
// Now we check for Builder pattern usage
mh = findNewBuilderMethod(clazz);
if (mh == null) {
final String pattern = "Class %s requires a public no-arg constructor or a public static "
+ "method that returns a corresponding Builder instance. The name of the static method "
+ "can either be %s or %s";
String error = String.format(pattern, clazz.getName(), METHOD_NAME_NEW_BUILDER,
METHOD_NAME_BUILDER);
throw new UnsupportedConstructionStrategyException(error);
}
Class<?> builderClass = mh.type().returnType();
metadataBuilder.setConstructionStrategy(ConstructorMetadata.ConstructionStrategy.BUILDER)
.setConstructorMethodHandle(mh).setBuilderClass(builderClass);
MethodHandle buildMethodHandle = IntrospectionUtils.findInstanceMethod(builderClass,
METHOD_NAME_BUILD, clazz);
if (buildMethodHandle == null) {
String pattern = "Class %s requires a public instance method, %s, with a return type of %s";
throw new EntityManagerException(
String.format(pattern, builderClass.getName(), METHOD_NAME_BUILD, clazz));
}
metadataBuilder.setBuildMethodHandle(buildMethodHandle);
} | [
"private",
"void",
"process",
"(",
")",
"{",
"metadataBuilder",
"=",
"ConstructorMetadata",
".",
"newBuilder",
"(",
")",
".",
"setClazz",
"(",
"clazz",
")",
";",
"MethodHandle",
"mh",
"=",
"IntrospectionUtils",
".",
"findDefaultConstructor",
"(",
"clazz",
")",
... | Introspects the class and builds the metadata. | [
"Introspects",
"the",
"class",
"and",
"builds",
"the",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/ConstructorIntrospector.java#L117-L149 |
134,772 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/ConstructorIntrospector.java | ConstructorIntrospector.findNewBuilderMethod | public static MethodHandle findNewBuilderMethod(Class<?> clazz) {
MethodHandle mh = null;
for (String methodName : NEW_BUILDER_METHOD_NAMES) {
mh = IntrospectionUtils.findStaticMethod(clazz, methodName, Object.class);
if (mh != null) {
break;
}
}
return mh;
} | java | public static MethodHandle findNewBuilderMethod(Class<?> clazz) {
MethodHandle mh = null;
for (String methodName : NEW_BUILDER_METHOD_NAMES) {
mh = IntrospectionUtils.findStaticMethod(clazz, methodName, Object.class);
if (mh != null) {
break;
}
}
return mh;
} | [
"public",
"static",
"MethodHandle",
"findNewBuilderMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"MethodHandle",
"mh",
"=",
"null",
";",
"for",
"(",
"String",
"methodName",
":",
"NEW_BUILDER_METHOD_NAMES",
")",
"{",
"mh",
"=",
"IntrospectionUtils",
... | Finds and returns a method handle for new instance of a Builder class.
@param clazz
the persistence class
@return the method handle for the newBuilder/builder method | [
"Finds",
"and",
"returns",
"a",
"method",
"handle",
"for",
"new",
"instance",
"of",
"a",
"Builder",
"class",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/ConstructorIntrospector.java#L158-L167 |
134,773 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshal | public static <T> T unmarshal(Entity nativeEntity, Class<T> entityClass) {
return unmarshalBaseEntity(nativeEntity, entityClass);
} | java | public static <T> T unmarshal(Entity nativeEntity, Class<T> entityClass) {
return unmarshalBaseEntity(nativeEntity, entityClass);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"unmarshal",
"(",
"Entity",
"nativeEntity",
",",
"Class",
"<",
"T",
">",
"entityClass",
")",
"{",
"return",
"unmarshalBaseEntity",
"(",
"nativeEntity",
",",
"entityClass",
")",
";",
"}"
] | Unmarshals the given native Entity into an object of given type, entityClass.
@param <T>
target object type
@param nativeEntity
the native Entity
@param entityClass
the target type
@return Object that is equivalent to the given native entity. If the given
<code>datastoreEntity</code> is <code>null</code>, returns <code>null</code>. | [
"Unmarshals",
"the",
"given",
"native",
"Entity",
"into",
"an",
"object",
"of",
"given",
"type",
"entityClass",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L81-L83 |
134,774 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshal | public static <T> T unmarshal(ProjectionEntity nativeEntity, Class<T> entityClass) {
return unmarshalBaseEntity(nativeEntity, entityClass);
} | java | public static <T> T unmarshal(ProjectionEntity nativeEntity, Class<T> entityClass) {
return unmarshalBaseEntity(nativeEntity, entityClass);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"unmarshal",
"(",
"ProjectionEntity",
"nativeEntity",
",",
"Class",
"<",
"T",
">",
"entityClass",
")",
"{",
"return",
"unmarshalBaseEntity",
"(",
"nativeEntity",
",",
"entityClass",
")",
";",
"}"
] | Unmarshals the given native ProjectionEntity into an object of given type, entityClass.
@param <T>
target object type
@param nativeEntity
the native Entity
@param entityClass
the target type
@return Object that is equivalent to the given native entity. If the given
<code>datastoreEntity</code> is <code>null</code>, returns <code>null</code>. | [
"Unmarshals",
"the",
"given",
"native",
"ProjectionEntity",
"into",
"an",
"object",
"of",
"given",
"type",
"entityClass",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L97-L99 |
134,775 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshal | @SuppressWarnings("unchecked")
private <T> T unmarshal() {
try {
instantiateEntity();
unmarshalIdentifier();
unmarshalKeyAndParentKey();
unmarshalProperties();
unmarshalEmbeddedFields();
// If using Builder pattern, invoke build method on the Builder to
// get the final entity.
ConstructorMetadata constructorMetadata = entityMetadata.getConstructorMetadata();
if (constructorMetadata.isBuilderConstructionStrategy()) {
entity = constructorMetadata.getBuildMethodHandle().invoke(entity);
}
return (T) entity;
} catch (EntityManagerException exp) {
throw exp;
} catch (Throwable t) {
throw new EntityManagerException(t.getMessage(), t);
}
} | java | @SuppressWarnings("unchecked")
private <T> T unmarshal() {
try {
instantiateEntity();
unmarshalIdentifier();
unmarshalKeyAndParentKey();
unmarshalProperties();
unmarshalEmbeddedFields();
// If using Builder pattern, invoke build method on the Builder to
// get the final entity.
ConstructorMetadata constructorMetadata = entityMetadata.getConstructorMetadata();
if (constructorMetadata.isBuilderConstructionStrategy()) {
entity = constructorMetadata.getBuildMethodHandle().invoke(entity);
}
return (T) entity;
} catch (EntityManagerException exp) {
throw exp;
} catch (Throwable t) {
throw new EntityManagerException(t.getMessage(), t);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
">",
"T",
"unmarshal",
"(",
")",
"{",
"try",
"{",
"instantiateEntity",
"(",
")",
";",
"unmarshalIdentifier",
"(",
")",
";",
"unmarshalKeyAndParentKey",
"(",
")",
";",
"unmarshalProperties... | Unmarshals the given Datastore Entity and returns the equivalent Entity POJO.
@param <T>
type
@return the entity POJO | [
"Unmarshals",
"the",
"given",
"Datastore",
"Entity",
"and",
"returns",
"the",
"equivalent",
"Entity",
"POJO",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L108-L129 |
134,776 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshalBaseEntity | private static <T> T unmarshalBaseEntity(BaseEntity<?> nativeEntity, Class<T> entityClass) {
if (nativeEntity == null) {
return null;
}
Unmarshaller unmarshaller = new Unmarshaller(nativeEntity, entityClass);
return unmarshaller.unmarshal();
} | java | private static <T> T unmarshalBaseEntity(BaseEntity<?> nativeEntity, Class<T> entityClass) {
if (nativeEntity == null) {
return null;
}
Unmarshaller unmarshaller = new Unmarshaller(nativeEntity, entityClass);
return unmarshaller.unmarshal();
} | [
"private",
"static",
"<",
"T",
">",
"T",
"unmarshalBaseEntity",
"(",
"BaseEntity",
"<",
"?",
">",
"nativeEntity",
",",
"Class",
"<",
"T",
">",
"entityClass",
")",
"{",
"if",
"(",
"nativeEntity",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Unma... | Unmarshals the given BaseEntity and returns the equivalent model object.
@param nativeEntity
the native entity to unmarshal
@param entityClass
the target type of the model class
@return the model object | [
"Unmarshals",
"the",
"given",
"BaseEntity",
"and",
"returns",
"the",
"equivalent",
"model",
"object",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L140-L146 |
134,777 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshalIdentifier | private void unmarshalIdentifier() throws Throwable {
IdentifierMetadata identifierMetadata = entityMetadata.getIdentifierMetadata();
Object id = ((Key) nativeEntity.getKey()).getNameOrId();
// If the ID is not a simple type...
IdClassMetadata idClassMetadata = identifierMetadata.getIdClassMetadata();
if (idClassMetadata != null) {
Object wrappedId = idClassMetadata.getConstructor().invoke(id);
id = wrappedId;
}
// Now set the ID (either simple or complex) on the Entity
MethodHandle writeMethod = identifierMetadata.getWriteMethod();
writeMethod.invoke(entity, id);
} | java | private void unmarshalIdentifier() throws Throwable {
IdentifierMetadata identifierMetadata = entityMetadata.getIdentifierMetadata();
Object id = ((Key) nativeEntity.getKey()).getNameOrId();
// If the ID is not a simple type...
IdClassMetadata idClassMetadata = identifierMetadata.getIdClassMetadata();
if (idClassMetadata != null) {
Object wrappedId = idClassMetadata.getConstructor().invoke(id);
id = wrappedId;
}
// Now set the ID (either simple or complex) on the Entity
MethodHandle writeMethod = identifierMetadata.getWriteMethod();
writeMethod.invoke(entity, id);
} | [
"private",
"void",
"unmarshalIdentifier",
"(",
")",
"throws",
"Throwable",
"{",
"IdentifierMetadata",
"identifierMetadata",
"=",
"entityMetadata",
".",
"getIdentifierMetadata",
"(",
")",
";",
"Object",
"id",
"=",
"(",
"(",
"Key",
")",
"nativeEntity",
".",
"getKey"... | Unamrshals the identifier.
@throws Throwable
propagated | [
"Unamrshals",
"the",
"identifier",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L161-L173 |
134,778 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshalKeyAndParentKey | private void unmarshalKeyAndParentKey() throws Throwable {
KeyMetadata keyMetadata = entityMetadata.getKeyMetadata();
if (keyMetadata != null) {
MethodHandle writeMethod = keyMetadata.getWriteMethod();
Key entityKey = (Key) nativeEntity.getKey();
writeMethod.invoke(entity, new DefaultDatastoreKey(entityKey));
}
ParentKeyMetadata parentKeyMetadata = entityMetadata.getParentKeyMetadata();
if (parentKeyMetadata != null) {
MethodHandle writeMethod = parentKeyMetadata.getWriteMethod();
Key parentKey = nativeEntity.getKey().getParent();
if (parentKey != null) {
writeMethod.invoke(entity, new DefaultDatastoreKey(parentKey));
}
}
} | java | private void unmarshalKeyAndParentKey() throws Throwable {
KeyMetadata keyMetadata = entityMetadata.getKeyMetadata();
if (keyMetadata != null) {
MethodHandle writeMethod = keyMetadata.getWriteMethod();
Key entityKey = (Key) nativeEntity.getKey();
writeMethod.invoke(entity, new DefaultDatastoreKey(entityKey));
}
ParentKeyMetadata parentKeyMetadata = entityMetadata.getParentKeyMetadata();
if (parentKeyMetadata != null) {
MethodHandle writeMethod = parentKeyMetadata.getWriteMethod();
Key parentKey = nativeEntity.getKey().getParent();
if (parentKey != null) {
writeMethod.invoke(entity, new DefaultDatastoreKey(parentKey));
}
}
} | [
"private",
"void",
"unmarshalKeyAndParentKey",
"(",
")",
"throws",
"Throwable",
"{",
"KeyMetadata",
"keyMetadata",
"=",
"entityMetadata",
".",
"getKeyMetadata",
"(",
")",
";",
"if",
"(",
"keyMetadata",
"!=",
"null",
")",
"{",
"MethodHandle",
"writeMethod",
"=",
... | Unamrshals the entity's key and parent key.
@throws Throwable
propagated | [
"Unamrshals",
"the",
"entity",
"s",
"key",
"and",
"parent",
"key",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L182-L198 |
134,779 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshalProperties | private void unmarshalProperties() throws Throwable {
Collection<PropertyMetadata> propertyMetadataCollection = entityMetadata
.getPropertyMetadataCollection();
for (PropertyMetadata propertyMetadata : propertyMetadataCollection) {
unmarshalProperty(propertyMetadata, entity);
}
} | java | private void unmarshalProperties() throws Throwable {
Collection<PropertyMetadata> propertyMetadataCollection = entityMetadata
.getPropertyMetadataCollection();
for (PropertyMetadata propertyMetadata : propertyMetadataCollection) {
unmarshalProperty(propertyMetadata, entity);
}
} | [
"private",
"void",
"unmarshalProperties",
"(",
")",
"throws",
"Throwable",
"{",
"Collection",
"<",
"PropertyMetadata",
">",
"propertyMetadataCollection",
"=",
"entityMetadata",
".",
"getPropertyMetadataCollection",
"(",
")",
";",
"for",
"(",
"PropertyMetadata",
"propert... | Unmarshal all the properties.
@throws Throwable
propagated | [
"Unmarshal",
"all",
"the",
"properties",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L206-L212 |
134,780 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshalEmbeddedFields | private void unmarshalEmbeddedFields() throws Throwable {
for (EmbeddedMetadata embeddedMetadata : entityMetadata.getEmbeddedMetadataCollection()) {
if (embeddedMetadata.getStorageStrategy() == StorageStrategy.EXPLODED) {
unmarshalWithExplodedStrategy(embeddedMetadata, entity);
} else {
unmarshalWithImplodedStrategy(embeddedMetadata, entity, nativeEntity);
}
}
} | java | private void unmarshalEmbeddedFields() throws Throwable {
for (EmbeddedMetadata embeddedMetadata : entityMetadata.getEmbeddedMetadataCollection()) {
if (embeddedMetadata.getStorageStrategy() == StorageStrategy.EXPLODED) {
unmarshalWithExplodedStrategy(embeddedMetadata, entity);
} else {
unmarshalWithImplodedStrategy(embeddedMetadata, entity, nativeEntity);
}
}
} | [
"private",
"void",
"unmarshalEmbeddedFields",
"(",
")",
"throws",
"Throwable",
"{",
"for",
"(",
"EmbeddedMetadata",
"embeddedMetadata",
":",
"entityMetadata",
".",
"getEmbeddedMetadataCollection",
"(",
")",
")",
"{",
"if",
"(",
"embeddedMetadata",
".",
"getStorageStra... | Unmarshals the embedded fields of this entity.
@throws Throwable
propagated | [
"Unmarshals",
"the",
"embedded",
"fields",
"of",
"this",
"entity",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L220-L228 |
134,781 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshalWithExplodedStrategy | private void unmarshalWithExplodedStrategy(EmbeddedMetadata embeddedMetadata, Object target)
throws Throwable {
Object embeddedObject = initializeEmbedded(embeddedMetadata, target);
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
unmarshalProperty(propertyMetadata, embeddedObject);
}
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
unmarshalWithExplodedStrategy(embeddedMetadata2, embeddedObject);
}
ConstructorMetadata constructorMetadata = embeddedMetadata.getConstructorMetadata();
if (constructorMetadata.isBuilderConstructionStrategy()) {
embeddedObject = constructorMetadata.getBuildMethodHandle().invoke(embeddedObject);
}
embeddedMetadata.getWriteMethod().invoke(target, embeddedObject);
} | java | private void unmarshalWithExplodedStrategy(EmbeddedMetadata embeddedMetadata, Object target)
throws Throwable {
Object embeddedObject = initializeEmbedded(embeddedMetadata, target);
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
unmarshalProperty(propertyMetadata, embeddedObject);
}
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
unmarshalWithExplodedStrategy(embeddedMetadata2, embeddedObject);
}
ConstructorMetadata constructorMetadata = embeddedMetadata.getConstructorMetadata();
if (constructorMetadata.isBuilderConstructionStrategy()) {
embeddedObject = constructorMetadata.getBuildMethodHandle().invoke(embeddedObject);
}
embeddedMetadata.getWriteMethod().invoke(target, embeddedObject);
} | [
"private",
"void",
"unmarshalWithExplodedStrategy",
"(",
"EmbeddedMetadata",
"embeddedMetadata",
",",
"Object",
"target",
")",
"throws",
"Throwable",
"{",
"Object",
"embeddedObject",
"=",
"initializeEmbedded",
"(",
"embeddedMetadata",
",",
"target",
")",
";",
"for",
"... | Unmarshals the embedded field represented by the given embedded metadata.
@param embeddedMetadata
the embedded metadata
@param target
the target object that needs to be updated
@throws Throwable
propagated | [
"Unmarshals",
"the",
"embedded",
"field",
"represented",
"by",
"the",
"given",
"embedded",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L240-L254 |
134,782 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshalWithImplodedStrategy | private static void unmarshalWithImplodedStrategy(EmbeddedMetadata embeddedMetadata,
Object target, BaseEntity<?> nativeEntity) throws Throwable {
Object embeddedObject = null;
ConstructorMetadata constructorMetadata = embeddedMetadata.getConstructorMetadata();
FullEntity<?> nativeEmbeddedEntity = null;
String propertyName = embeddedMetadata.getMappedName();
if (nativeEntity.contains(propertyName)) {
Value<?> nativeValue = nativeEntity.getValue(propertyName);
if (nativeValue instanceof NullValue) {
embeddedMetadata.getWriteMethod().invoke(target, embeddedObject);
} else {
nativeEmbeddedEntity = ((EntityValue) nativeValue).get();
embeddedObject = constructorMetadata.getConstructorMethodHandle().invoke();
}
}
if (embeddedObject == null) {
return;
}
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
unmarshalProperty(propertyMetadata, embeddedObject, nativeEmbeddedEntity);
}
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
unmarshalWithImplodedStrategy(embeddedMetadata2, embeddedObject, nativeEmbeddedEntity);
}
if (constructorMetadata.isBuilderConstructionStrategy()) {
embeddedObject = constructorMetadata.getBuildMethodHandle().invoke(embeddedObject);
}
embeddedMetadata.getWriteMethod().invoke(target, embeddedObject);
} | java | private static void unmarshalWithImplodedStrategy(EmbeddedMetadata embeddedMetadata,
Object target, BaseEntity<?> nativeEntity) throws Throwable {
Object embeddedObject = null;
ConstructorMetadata constructorMetadata = embeddedMetadata.getConstructorMetadata();
FullEntity<?> nativeEmbeddedEntity = null;
String propertyName = embeddedMetadata.getMappedName();
if (nativeEntity.contains(propertyName)) {
Value<?> nativeValue = nativeEntity.getValue(propertyName);
if (nativeValue instanceof NullValue) {
embeddedMetadata.getWriteMethod().invoke(target, embeddedObject);
} else {
nativeEmbeddedEntity = ((EntityValue) nativeValue).get();
embeddedObject = constructorMetadata.getConstructorMethodHandle().invoke();
}
}
if (embeddedObject == null) {
return;
}
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
unmarshalProperty(propertyMetadata, embeddedObject, nativeEmbeddedEntity);
}
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
unmarshalWithImplodedStrategy(embeddedMetadata2, embeddedObject, nativeEmbeddedEntity);
}
if (constructorMetadata.isBuilderConstructionStrategy()) {
embeddedObject = constructorMetadata.getBuildMethodHandle().invoke(embeddedObject);
}
embeddedMetadata.getWriteMethod().invoke(target, embeddedObject);
} | [
"private",
"static",
"void",
"unmarshalWithImplodedStrategy",
"(",
"EmbeddedMetadata",
"embeddedMetadata",
",",
"Object",
"target",
",",
"BaseEntity",
"<",
"?",
">",
"nativeEntity",
")",
"throws",
"Throwable",
"{",
"Object",
"embeddedObject",
"=",
"null",
";",
"Cons... | Unmarshals the embedded field represented by the given metadata.
@param embeddedMetadata
the metadata of the field to unmarshal
@param target
the object in which the embedded field is declared/accessible from
@param nativeEntity
the native entity from which the embedded entity is to be extracted
@throws Throwable
propagated | [
"Unmarshals",
"the",
"embedded",
"field",
"represented",
"by",
"the",
"given",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L268-L296 |
134,783 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java | Unmarshaller.unmarshalProperty | private void unmarshalProperty(PropertyMetadata propertyMetadata, Object target)
throws Throwable {
unmarshalProperty(propertyMetadata, target, nativeEntity);
} | java | private void unmarshalProperty(PropertyMetadata propertyMetadata, Object target)
throws Throwable {
unmarshalProperty(propertyMetadata, target, nativeEntity);
} | [
"private",
"void",
"unmarshalProperty",
"(",
"PropertyMetadata",
"propertyMetadata",
",",
"Object",
"target",
")",
"throws",
"Throwable",
"{",
"unmarshalProperty",
"(",
"propertyMetadata",
",",
"target",
",",
"nativeEntity",
")",
";",
"}"
] | Unmarshals the property represented by the given property metadata and updates the target
object with the property value.
@param propertyMetadata
the property metadata
@param target
the target object to update
@throws Throwable
propagated | [
"Unmarshals",
"the",
"property",
"represented",
"by",
"the",
"given",
"property",
"metadata",
"and",
"updates",
"the",
"target",
"object",
"with",
"the",
"property",
"value",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/Unmarshaller.java#L309-L312 |
134,784 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java | EntityMetadata.setIdentifierMetadata | public void setIdentifierMetadata(IdentifierMetadata identifierMetadata) {
if (this.identifierMetadata != null) {
String format = "Class %s has at least two fields, %s and %s, marked with %s annotation. "
+ "Only one field can be marked as an identifier. ";
String message = String.format(format, entityClass.getName(),
this.identifierMetadata.getName(), identifierMetadata.getName(),
Identifier.class.getName());
throw new EntityManagerException(message);
}
this.identifierMetadata = identifierMetadata;
} | java | public void setIdentifierMetadata(IdentifierMetadata identifierMetadata) {
if (this.identifierMetadata != null) {
String format = "Class %s has at least two fields, %s and %s, marked with %s annotation. "
+ "Only one field can be marked as an identifier. ";
String message = String.format(format, entityClass.getName(),
this.identifierMetadata.getName(), identifierMetadata.getName(),
Identifier.class.getName());
throw new EntityManagerException(message);
}
this.identifierMetadata = identifierMetadata;
} | [
"public",
"void",
"setIdentifierMetadata",
"(",
"IdentifierMetadata",
"identifierMetadata",
")",
"{",
"if",
"(",
"this",
".",
"identifierMetadata",
"!=",
"null",
")",
"{",
"String",
"format",
"=",
"\"Class %s has at least two fields, %s and %s, marked with %s annotation. \"",... | Sets the metadata of the identifier. An exception will be thrown if there is an
IdentifierMetadata already set.
@param identifierMetadata
the metadata of the identifier. | [
"Sets",
"the",
"metadata",
"of",
"the",
"identifier",
".",
"An",
"exception",
"will",
"be",
"thrown",
"if",
"there",
"is",
"an",
"IdentifierMetadata",
"already",
"set",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java#L181-L191 |
134,785 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java | EntityMetadata.setKeyMetadata | public void setKeyMetadata(KeyMetadata keyMetadata) {
if (this.keyMetadata != null) {
String format = "Class %s has two fields, %s and %s marked with %s annotation. Only one "
+ "field can be marked as Key. ";
String message = String.format(format, entityClass.getName(), this.keyMetadata.getName(),
keyMetadata.getName(), Key.class.getName());
throw new EntityManagerException(message);
}
this.keyMetadata = keyMetadata;
} | java | public void setKeyMetadata(KeyMetadata keyMetadata) {
if (this.keyMetadata != null) {
String format = "Class %s has two fields, %s and %s marked with %s annotation. Only one "
+ "field can be marked as Key. ";
String message = String.format(format, entityClass.getName(), this.keyMetadata.getName(),
keyMetadata.getName(), Key.class.getName());
throw new EntityManagerException(message);
}
this.keyMetadata = keyMetadata;
} | [
"public",
"void",
"setKeyMetadata",
"(",
"KeyMetadata",
"keyMetadata",
")",
"{",
"if",
"(",
"this",
".",
"keyMetadata",
"!=",
"null",
")",
"{",
"String",
"format",
"=",
"\"Class %s has two fields, %s and %s marked with %s annotation. Only one \"",
"+",
"\"field can be mar... | Sets the metadata of the Key field.
@param keyMetadata
the key metadata. | [
"Sets",
"the",
"metadata",
"of",
"the",
"Key",
"field",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java#L209-L219 |
134,786 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java | EntityMetadata.setParentKetMetadata | public void setParentKetMetadata(ParentKeyMetadata parentKeyMetadata) {
if (this.parentKeyMetadata != null) {
String format = "Class %s has two fields, %s and %s marked with %s annotation. Only one "
+ "field can be marked as ParentKey. ";
String message = String.format(format, entityClass.getName(),
this.parentKeyMetadata.getName(), parentKeyMetadata.getName(), ParentKey.class.getName());
throw new EntityManagerException(message);
}
this.parentKeyMetadata = parentKeyMetadata;
} | java | public void setParentKetMetadata(ParentKeyMetadata parentKeyMetadata) {
if (this.parentKeyMetadata != null) {
String format = "Class %s has two fields, %s and %s marked with %s annotation. Only one "
+ "field can be marked as ParentKey. ";
String message = String.format(format, entityClass.getName(),
this.parentKeyMetadata.getName(), parentKeyMetadata.getName(), ParentKey.class.getName());
throw new EntityManagerException(message);
}
this.parentKeyMetadata = parentKeyMetadata;
} | [
"public",
"void",
"setParentKetMetadata",
"(",
"ParentKeyMetadata",
"parentKeyMetadata",
")",
"{",
"if",
"(",
"this",
".",
"parentKeyMetadata",
"!=",
"null",
")",
"{",
"String",
"format",
"=",
"\"Class %s has two fields, %s and %s marked with %s annotation. Only one \"",
"+... | Sets the metadata about the parent key.
@param parentKeyMetadata
the parent key metadata. | [
"Sets",
"the",
"metadata",
"about",
"the",
"parent",
"key",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java#L236-L246 |
134,787 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java | EntityMetadata.setVersionMetadata | public void setVersionMetadata(PropertyMetadata versionMetadata) {
if (this.versionMetadata != null) {
throwDuplicateAnnotationException(entityClass, Version.class, this.versionMetadata,
versionMetadata);
}
this.versionMetadata = versionMetadata;
} | java | public void setVersionMetadata(PropertyMetadata versionMetadata) {
if (this.versionMetadata != null) {
throwDuplicateAnnotationException(entityClass, Version.class, this.versionMetadata,
versionMetadata);
}
this.versionMetadata = versionMetadata;
} | [
"public",
"void",
"setVersionMetadata",
"(",
"PropertyMetadata",
"versionMetadata",
")",
"{",
"if",
"(",
"this",
".",
"versionMetadata",
"!=",
"null",
")",
"{",
"throwDuplicateAnnotationException",
"(",
"entityClass",
",",
"Version",
".",
"class",
",",
"this",
"."... | Sets the metadata of the field that is used for optimistic locking.
@param versionMetadata
metadata of the field that is used for optimistic locking. | [
"Sets",
"the",
"metadata",
"of",
"the",
"field",
"that",
"is",
"used",
"for",
"optimistic",
"locking",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java#L263-L269 |
134,788 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java | EntityMetadata.setCreatedTimestampMetadata | public void setCreatedTimestampMetadata(PropertyMetadata createdTimestampMetadata) {
if (this.createdTimestampMetadata != null) {
throwDuplicateAnnotationException(entityClass, CreatedTimestamp.class,
this.createdTimestampMetadata, createdTimestampMetadata);
}
this.createdTimestampMetadata = createdTimestampMetadata;
} | java | public void setCreatedTimestampMetadata(PropertyMetadata createdTimestampMetadata) {
if (this.createdTimestampMetadata != null) {
throwDuplicateAnnotationException(entityClass, CreatedTimestamp.class,
this.createdTimestampMetadata, createdTimestampMetadata);
}
this.createdTimestampMetadata = createdTimestampMetadata;
} | [
"public",
"void",
"setCreatedTimestampMetadata",
"(",
"PropertyMetadata",
"createdTimestampMetadata",
")",
"{",
"if",
"(",
"this",
".",
"createdTimestampMetadata",
"!=",
"null",
")",
"{",
"throwDuplicateAnnotationException",
"(",
"entityClass",
",",
"CreatedTimestamp",
".... | Sets the created timestamp metadata to the given value.
@param createdTimestampMetadata
the created timestamp metadata | [
"Sets",
"the",
"created",
"timestamp",
"metadata",
"to",
"the",
"given",
"value",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java#L288-L294 |
134,789 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java | EntityMetadata.updateMasterPropertyMetadataMap | public void updateMasterPropertyMetadataMap(String mappedName, String qualifiedName) {
String old = masterPropertyMetadataMap.put(mappedName, qualifiedName);
if (old != null) {
String message = "Duplicate property %s in entity %s. Check fields %s and %s";
throw new EntityManagerException(
String.format(message, mappedName, entityClass.getName(), old, qualifiedName));
}
} | java | public void updateMasterPropertyMetadataMap(String mappedName, String qualifiedName) {
String old = masterPropertyMetadataMap.put(mappedName, qualifiedName);
if (old != null) {
String message = "Duplicate property %s in entity %s. Check fields %s and %s";
throw new EntityManagerException(
String.format(message, mappedName, entityClass.getName(), old, qualifiedName));
}
} | [
"public",
"void",
"updateMasterPropertyMetadataMap",
"(",
"String",
"mappedName",
",",
"String",
"qualifiedName",
")",
"{",
"String",
"old",
"=",
"masterPropertyMetadataMap",
".",
"put",
"(",
"mappedName",
",",
"qualifiedName",
")",
";",
"if",
"(",
"old",
"!=",
... | Updates the master property metadata map with the given property metadata.
@param mappedName
the mapped name (or property name in the datastore)
@param qualifiedName
the qualified name of the field
@throws EntityManagerException
if a property with the same mapped name already exists. | [
"Updates",
"the",
"master",
"property",
"metadata",
"map",
"with",
"the",
"given",
"property",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java#L352-L360 |
134,790 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java | EntityMetadata.ensureUniqueProperties | private void ensureUniqueProperties(EmbeddedMetadata embeddedMetadata,
StorageStrategy storageStrategy) {
if (embeddedMetadata.getStorageStrategy() == StorageStrategy.EXPLODED) {
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
updateMasterPropertyMetadataMap(propertyMetadata.getMappedName(),
embeddedMetadata.getField().getQualifiedName() + "." + propertyMetadata.getName());
}
// Run through the nested embedded objects recursively
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
ensureUniqueProperties(embeddedMetadata2, storageStrategy);
}
} else {
// IMPLODED storage strategy... we don't have to check the
// individual properties or nested embeddables
updateMasterPropertyMetadataMap(embeddedMetadata.getMappedName(),
embeddedMetadata.getField().getQualifiedName());
}
} | java | private void ensureUniqueProperties(EmbeddedMetadata embeddedMetadata,
StorageStrategy storageStrategy) {
if (embeddedMetadata.getStorageStrategy() == StorageStrategy.EXPLODED) {
for (PropertyMetadata propertyMetadata : embeddedMetadata.getPropertyMetadataCollection()) {
updateMasterPropertyMetadataMap(propertyMetadata.getMappedName(),
embeddedMetadata.getField().getQualifiedName() + "." + propertyMetadata.getName());
}
// Run through the nested embedded objects recursively
for (EmbeddedMetadata embeddedMetadata2 : embeddedMetadata.getEmbeddedMetadataCollection()) {
ensureUniqueProperties(embeddedMetadata2, storageStrategy);
}
} else {
// IMPLODED storage strategy... we don't have to check the
// individual properties or nested embeddables
updateMasterPropertyMetadataMap(embeddedMetadata.getMappedName(),
embeddedMetadata.getField().getQualifiedName());
}
} | [
"private",
"void",
"ensureUniqueProperties",
"(",
"EmbeddedMetadata",
"embeddedMetadata",
",",
"StorageStrategy",
"storageStrategy",
")",
"{",
"if",
"(",
"embeddedMetadata",
".",
"getStorageStrategy",
"(",
")",
"==",
"StorageStrategy",
".",
"EXPLODED",
")",
"{",
"for"... | Validates the embedded field represented by the given metadata to ensure there are no duplicate
property names defined across the entity.
@param embeddedMetadata
the metadata of the embedded field
@param storageStrategy
the storage strategy of the embedded field | [
"Validates",
"the",
"embedded",
"field",
"represented",
"by",
"the",
"given",
"metadata",
"to",
"ensure",
"there",
"are",
"no",
"duplicate",
"property",
"names",
"defined",
"across",
"the",
"entity",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java#L413-L430 |
134,791 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java | EntityMetadata.throwDuplicateAnnotationException | private static void throwDuplicateAnnotationException(Class<?> entityClass,
Class<? extends Annotation> annotationClass, PropertyMetadata metadata1,
PropertyMetadata metadata2) {
String format = "Class %s has at least two fields, %s and %s, with an annotation of %s. "
+ "A given entity can have at most one field with this annotation. ";
String message = String.format(format, entityClass.getName(), metadata1.getName(),
metadata2.getName(), annotationClass.getName());
throw new EntityManagerException(message);
} | java | private static void throwDuplicateAnnotationException(Class<?> entityClass,
Class<? extends Annotation> annotationClass, PropertyMetadata metadata1,
PropertyMetadata metadata2) {
String format = "Class %s has at least two fields, %s and %s, with an annotation of %s. "
+ "A given entity can have at most one field with this annotation. ";
String message = String.format(format, entityClass.getName(), metadata1.getName(),
metadata2.getName(), annotationClass.getName());
throw new EntityManagerException(message);
} | [
"private",
"static",
"void",
"throwDuplicateAnnotationException",
"(",
"Class",
"<",
"?",
">",
"entityClass",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
",",
"PropertyMetadata",
"metadata1",
",",
"PropertyMetadata",
"metadata2",
")",
"{... | Raises an exception with a detailed message reporting that the entity has more than one field
that has a specific annotation.
@param entityClass
the entity class
@param annotationClass
the annotation class
@param metadata1
the metadata of the first field
@param metadata2
the metadata of the second field that conflicts with the first | [
"Raises",
"an",
"exception",
"with",
"a",
"detailed",
"message",
"reporting",
"that",
"the",
"entity",
"has",
"more",
"than",
"one",
"field",
"that",
"has",
"a",
"specific",
"annotation",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EntityMetadata.java#L445-L453 |
134,792 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/ExternalListenerIntrospector.java | ExternalListenerIntrospector.introspect | public static ExternalListenerMetadata introspect(Class<?> listenerClass) {
ExternalListenerMetadata cachedMetadata = cache.get(listenerClass);
if (cachedMetadata != null) {
return cachedMetadata;
}
synchronized (listenerClass) {
cachedMetadata = cache.get(listenerClass);
if (cachedMetadata != null) {
return cachedMetadata;
}
ExternalListenerIntrospector introspector = new ExternalListenerIntrospector(listenerClass);
introspector.introspect();
cache.put(listenerClass, introspector.metadata);
return introspector.metadata;
}
} | java | public static ExternalListenerMetadata introspect(Class<?> listenerClass) {
ExternalListenerMetadata cachedMetadata = cache.get(listenerClass);
if (cachedMetadata != null) {
return cachedMetadata;
}
synchronized (listenerClass) {
cachedMetadata = cache.get(listenerClass);
if (cachedMetadata != null) {
return cachedMetadata;
}
ExternalListenerIntrospector introspector = new ExternalListenerIntrospector(listenerClass);
introspector.introspect();
cache.put(listenerClass, introspector.metadata);
return introspector.metadata;
}
} | [
"public",
"static",
"ExternalListenerMetadata",
"introspect",
"(",
"Class",
"<",
"?",
">",
"listenerClass",
")",
"{",
"ExternalListenerMetadata",
"cachedMetadata",
"=",
"cache",
".",
"get",
"(",
"listenerClass",
")",
";",
"if",
"(",
"cachedMetadata",
"!=",
"null",... | Introspects the given entity listener class and returns its metadata.
@param listenerClass
the entity listener class
@return the entity listener metadata | [
"Introspects",
"the",
"given",
"entity",
"listener",
"class",
"and",
"returns",
"its",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/ExternalListenerIntrospector.java#L65-L80 |
134,793 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/ExternalListenerIntrospector.java | ExternalListenerIntrospector.introspect | private void introspect() {
if (!listenerClass.isAnnotationPresent(EntityListener.class)) {
String message = String.format(
"Class %s must have %s annotation to be used as an EntityListener",
listenerClass.getName(), EntityListener.class.getName());
throw new EntityManagerException(message);
}
metadata = new ExternalListenerMetadata(listenerClass);
processMethods();
} | java | private void introspect() {
if (!listenerClass.isAnnotationPresent(EntityListener.class)) {
String message = String.format(
"Class %s must have %s annotation to be used as an EntityListener",
listenerClass.getName(), EntityListener.class.getName());
throw new EntityManagerException(message);
}
metadata = new ExternalListenerMetadata(listenerClass);
processMethods();
} | [
"private",
"void",
"introspect",
"(",
")",
"{",
"if",
"(",
"!",
"listenerClass",
".",
"isAnnotationPresent",
"(",
"EntityListener",
".",
"class",
")",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Class %s must have %s annotation to be used ... | Introspects the listener class and creates the metadata. | [
"Introspects",
"the",
"listener",
"class",
"and",
"creates",
"the",
"metadata",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/ExternalListenerIntrospector.java#L85-L94 |
134,794 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/MapperFactory.java | MapperFactory.getMapper | public Mapper getMapper(Field field) {
PropertyMapper propertyMapperAnnotation = field.getAnnotation(PropertyMapper.class);
if (propertyMapperAnnotation != null) {
return createCustomMapper(field, propertyMapperAnnotation);
}
Class<?> fieldType = field.getType();
if (fieldType.equals(BigDecimal.class)) {
Decimal decimalAnnotation = field.getAnnotation(Decimal.class);
if (decimalAnnotation != null) {
return new DecimalMapper(decimalAnnotation.precision(), decimalAnnotation.scale());
}
}
if (List.class.isAssignableFrom(fieldType) || Set.class.isAssignableFrom(fieldType)) {
return CollectionMapperFactory.getInstance().getMapper(field);
}
return getMapper(field.getGenericType());
} | java | public Mapper getMapper(Field field) {
PropertyMapper propertyMapperAnnotation = field.getAnnotation(PropertyMapper.class);
if (propertyMapperAnnotation != null) {
return createCustomMapper(field, propertyMapperAnnotation);
}
Class<?> fieldType = field.getType();
if (fieldType.equals(BigDecimal.class)) {
Decimal decimalAnnotation = field.getAnnotation(Decimal.class);
if (decimalAnnotation != null) {
return new DecimalMapper(decimalAnnotation.precision(), decimalAnnotation.scale());
}
}
if (List.class.isAssignableFrom(fieldType) || Set.class.isAssignableFrom(fieldType)) {
return CollectionMapperFactory.getInstance().getMapper(field);
}
return getMapper(field.getGenericType());
} | [
"public",
"Mapper",
"getMapper",
"(",
"Field",
"field",
")",
"{",
"PropertyMapper",
"propertyMapperAnnotation",
"=",
"field",
".",
"getAnnotation",
"(",
"PropertyMapper",
".",
"class",
")",
";",
"if",
"(",
"propertyMapperAnnotation",
"!=",
"null",
")",
"{",
"ret... | Returns the mapper for the given field. If the field has a custom mapper, a new instance of the
specified mapper will be created and returned. Otherwise, one of the built-in mappers will be
returned based on the field type.
@param field
the field
@return the mapper for the given field. | [
"Returns",
"the",
"mapper",
"for",
"the",
"given",
"field",
".",
"If",
"the",
"field",
"has",
"a",
"custom",
"mapper",
"a",
"new",
"instance",
"of",
"the",
"specified",
"mapper",
"will",
"be",
"created",
"and",
"returned",
".",
"Otherwise",
"one",
"of",
... | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/MapperFactory.java#L116-L132 |
134,795 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/MapperFactory.java | MapperFactory.getMapper | public Mapper getMapper(Type type) {
Mapper mapper = cache.get(type);
if (mapper == null) {
mapper = createMapper(type);
}
return mapper;
} | java | public Mapper getMapper(Type type) {
Mapper mapper = cache.get(type);
if (mapper == null) {
mapper = createMapper(type);
}
return mapper;
} | [
"public",
"Mapper",
"getMapper",
"(",
"Type",
"type",
")",
"{",
"Mapper",
"mapper",
"=",
"cache",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"mapper",
"==",
"null",
")",
"{",
"mapper",
"=",
"createMapper",
"(",
"type",
")",
";",
"}",
"return",
"... | Returns a mapper for the given type. If a mapper that can handle given type exists in the
cache, it will be returned. Otherwise, a new mapper will be created.
@param type
the type of field in the model class
@return a {@link Mapper} that is capable of mapping the given type. | [
"Returns",
"a",
"mapper",
"for",
"the",
"given",
"type",
".",
"If",
"a",
"mapper",
"that",
"can",
"handle",
"given",
"type",
"exists",
"in",
"the",
"cache",
"it",
"will",
"be",
"returned",
".",
"Otherwise",
"a",
"new",
"mapper",
"will",
"be",
"created",
... | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/MapperFactory.java#L142-L148 |
134,796 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/MapperFactory.java | MapperFactory.setDefaultMapper | public void setDefaultMapper(Type type, Mapper mapper) {
if (mapper == null) {
throw new IllegalArgumentException("mapper cannot be null");
}
lock.lock();
try {
cache.put(type, mapper);
} finally {
lock.unlock();
}
} | java | public void setDefaultMapper(Type type, Mapper mapper) {
if (mapper == null) {
throw new IllegalArgumentException("mapper cannot be null");
}
lock.lock();
try {
cache.put(type, mapper);
} finally {
lock.unlock();
}
} | [
"public",
"void",
"setDefaultMapper",
"(",
"Type",
"type",
",",
"Mapper",
"mapper",
")",
"{",
"if",
"(",
"mapper",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"mapper cannot be null\"",
")",
";",
"}",
"lock",
".",
"lock",
"(",
... | Sets or registers the given mapper for the given type. This method must be called before
performing any persistence operations, preferably, during application startup. Entities that
were introspected before calling this method will NOT use the new mapper.
@param type
the type
@param mapper
the mapper to use for the given type | [
"Sets",
"or",
"registers",
"the",
"given",
"mapper",
"for",
"the",
"given",
"type",
".",
"This",
"method",
"must",
"be",
"called",
"before",
"performing",
"any",
"persistence",
"operations",
"preferably",
"during",
"application",
"startup",
".",
"Entities",
"tha... | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/MapperFactory.java#L160-L170 |
134,797 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/MapperFactory.java | MapperFactory.createMapper | private Mapper createMapper(Type type) {
lock.lock();
try {
Mapper mapper = cache.get(type);
if (mapper != null) {
return mapper;
}
if (type instanceof Class) {
mapper = createMapper((Class<?>) type);
} else if (type instanceof ParameterizedType) {
mapper = createMapper((ParameterizedType) type);
} else {
throw new IllegalArgumentException(
String.format("Type %s is neither a Class nor ParameterizedType", type));
}
cache.put(type, mapper);
return mapper;
} finally {
lock.unlock();
}
} | java | private Mapper createMapper(Type type) {
lock.lock();
try {
Mapper mapper = cache.get(type);
if (mapper != null) {
return mapper;
}
if (type instanceof Class) {
mapper = createMapper((Class<?>) type);
} else if (type instanceof ParameterizedType) {
mapper = createMapper((ParameterizedType) type);
} else {
throw new IllegalArgumentException(
String.format("Type %s is neither a Class nor ParameterizedType", type));
}
cache.put(type, mapper);
return mapper;
} finally {
lock.unlock();
}
} | [
"private",
"Mapper",
"createMapper",
"(",
"Type",
"type",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"Mapper",
"mapper",
"=",
"cache",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"mapper",
"!=",
"null",
")",
"{",
"return",
"mapper"... | Creates a new mapper for the given type.
@param type
the type for which a mapper is to be created
@return a mapper that can handle the mapping of given type to/from the Cloud Datastore. | [
"Creates",
"a",
"new",
"mapper",
"for",
"the",
"given",
"type",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/MapperFactory.java#L179-L199 |
134,798 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/MapperFactory.java | MapperFactory.createMapper | private Mapper createMapper(Class<?> clazz) {
Mapper mapper;
if (Enum.class.isAssignableFrom(clazz)) {
mapper = new EnumMapper(clazz);
} else if (Map.class.isAssignableFrom(clazz)) {
mapper = new MapMapper(clazz);
} else if (clazz.isAnnotationPresent(Embeddable.class)) {
mapper = new EmbeddedObjectMapper(clazz);
} else {
throw new NoSuitableMapperException(
String.format("No mapper found for class %s", clazz.getName()));
}
return mapper;
} | java | private Mapper createMapper(Class<?> clazz) {
Mapper mapper;
if (Enum.class.isAssignableFrom(clazz)) {
mapper = new EnumMapper(clazz);
} else if (Map.class.isAssignableFrom(clazz)) {
mapper = new MapMapper(clazz);
} else if (clazz.isAnnotationPresent(Embeddable.class)) {
mapper = new EmbeddedObjectMapper(clazz);
} else {
throw new NoSuitableMapperException(
String.format("No mapper found for class %s", clazz.getName()));
}
return mapper;
} | [
"private",
"Mapper",
"createMapper",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Mapper",
"mapper",
";",
"if",
"(",
"Enum",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
")",
"{",
"mapper",
"=",
"new",
"EnumMapper",
"(",
"clazz",
")",
... | Creates a mapper for the given class.
@param clazz
the class
@return the mapper for the given class. | [
"Creates",
"a",
"mapper",
"for",
"the",
"given",
"class",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/MapperFactory.java#L208-L221 |
134,799 | sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/MapperFactory.java | MapperFactory.createDefaultMappers | private void createDefaultMappers() {
BooleanMapper booleanMapper = new BooleanMapper();
CharMapper charMapper = new CharMapper();
ShortMapper shortMapper = new ShortMapper();
IntegerMapper integerMapper = new IntegerMapper();
LongMapper longMapper = new LongMapper();
FloatMapper floatMapper = new FloatMapper();
DoubleMapper doubleMapper = new DoubleMapper();
cache.put(boolean.class, booleanMapper);
cache.put(Boolean.class, booleanMapper);
cache.put(char.class, charMapper);
cache.put(Character.class, charMapper);
cache.put(short.class, shortMapper);
cache.put(Short.class, shortMapper);
cache.put(int.class, integerMapper);
cache.put(Integer.class, integerMapper);
cache.put(long.class, longMapper);
cache.put(Long.class, longMapper);
cache.put(float.class, floatMapper);
cache.put(Float.class, floatMapper);
cache.put(double.class, doubleMapper);
cache.put(Double.class, doubleMapper);
cache.put(String.class, new StringMapper());
cache.put(BigDecimal.class, new BigDecimalMapper());
cache.put(byte[].class, new ByteArrayMapper());
cache.put(char[].class, new CharArrayMapper());
cache.put(Date.class, new DateMapper());
cache.put(Calendar.class, new CalendarMapper());
cache.put(GeoLocation.class, new GeoLocationMapper());
cache.put(DatastoreKey.class, new KeyMapper());
cache.put(LocalDate.class, new LocalDateMapper());
cache.put(LocalTime.class, new LocalTimeMapper());
cache.put(LocalDateTime.class, new LocalDateTimeMapper());
cache.put(OffsetDateTime.class, new OffsetDateTimeMapper());
cache.put(ZonedDateTime.class, new ZonedDateTimeMapper());
} | java | private void createDefaultMappers() {
BooleanMapper booleanMapper = new BooleanMapper();
CharMapper charMapper = new CharMapper();
ShortMapper shortMapper = new ShortMapper();
IntegerMapper integerMapper = new IntegerMapper();
LongMapper longMapper = new LongMapper();
FloatMapper floatMapper = new FloatMapper();
DoubleMapper doubleMapper = new DoubleMapper();
cache.put(boolean.class, booleanMapper);
cache.put(Boolean.class, booleanMapper);
cache.put(char.class, charMapper);
cache.put(Character.class, charMapper);
cache.put(short.class, shortMapper);
cache.put(Short.class, shortMapper);
cache.put(int.class, integerMapper);
cache.put(Integer.class, integerMapper);
cache.put(long.class, longMapper);
cache.put(Long.class, longMapper);
cache.put(float.class, floatMapper);
cache.put(Float.class, floatMapper);
cache.put(double.class, doubleMapper);
cache.put(Double.class, doubleMapper);
cache.put(String.class, new StringMapper());
cache.put(BigDecimal.class, new BigDecimalMapper());
cache.put(byte[].class, new ByteArrayMapper());
cache.put(char[].class, new CharArrayMapper());
cache.put(Date.class, new DateMapper());
cache.put(Calendar.class, new CalendarMapper());
cache.put(GeoLocation.class, new GeoLocationMapper());
cache.put(DatastoreKey.class, new KeyMapper());
cache.put(LocalDate.class, new LocalDateMapper());
cache.put(LocalTime.class, new LocalTimeMapper());
cache.put(LocalDateTime.class, new LocalDateTimeMapper());
cache.put(OffsetDateTime.class, new OffsetDateTimeMapper());
cache.put(ZonedDateTime.class, new ZonedDateTimeMapper());
} | [
"private",
"void",
"createDefaultMappers",
"(",
")",
"{",
"BooleanMapper",
"booleanMapper",
"=",
"new",
"BooleanMapper",
"(",
")",
";",
"CharMapper",
"charMapper",
"=",
"new",
"CharMapper",
"(",
")",
";",
"ShortMapper",
"shortMapper",
"=",
"new",
"ShortMapper",
... | Creates and assigns default Mappers various common types. | [
"Creates",
"and",
"assigns",
"default",
"Mappers",
"various",
"common",
"types",
"."
] | 96d4c6dce3a5009624f7112a398406914dd19165 | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/MapperFactory.java#L250-L286 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.