@Override public MethodSpec buildRemover(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { // Add the abstract modifier to the signature, because there is no implementation in the interface: return buildSignature(domainClazz, config) .toBuilder() .addModifiers(Modifier.ABSTRACT) .build(); } }
@Override public MethodSpec buildAdderAll(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { // Add the abstract modifier to the signature, because there is no implementation in the interface: return buildSignature(domainClazz, config) .toBuilder() .addModifiers(Modifier.ABSTRACT) .build(); } }
@Override public MethodSpec buildRemoverAll(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { // Add the abstract modifier to the signature, because there is no implementation in the interface: return buildSignature(domainClazz, config) .toBuilder() .addModifiers(Modifier.ABSTRACT) .build(); } }
@Override public MethodSpec buildAdder(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { // Add the abstract modifier to the signature, because there is no implementation in the interface: return buildSignature(domainClazz, config) .toBuilder() .addModifiers(Modifier.ABSTRACT) .build(); } }
@Override public MethodSpec buildVarArgSetter(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { // Get the signature of the vararg setter for this property: MethodSpec signature = buildSignature(domainClazz, config); if (signature != null) { // Add an abstract modifier to the signature: return signature.toBuilder() .addModifiers(Modifier.ABSTRACT) .build(); } else { return null; } } }
/** * {@inheritDoc} */ @Override public MethodSpec buildVarArgSetterImplementation(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { // Get the signature of a setter for this property: MethodSpec signature = buildSignature(domainClazz, config); if(signature != null) { // Add the setter implementation code to the signature: return addSetterImplementationCode(signature.toBuilder(), domainClazz, config, false) .build(); } else { return null; } } }
@Override public MethodSpec buildGetter(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { // @Iri annotation of the property: AnnotationSpec iriAnnotation = AnnotationSpec.builder(Iri.class) .addMember("value", "$S", getResourceAsString()) .build(); return buildSignature(domainClazz, config) .toBuilder() .addModifiers(Modifier.ABSTRACT) .addAnnotation(iriAnnotation) .addAnnotations(buildSchemaAnnotations(domainClazz, config)) .build(); } }
@Override public MethodSpec buildSetter(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { // @Iri annotation of the property: AnnotationSpec iriAnnotation = AnnotationSpec.builder(Iri.class) .addMember("value", "$S", getResourceAsString()) .build(); // Get the signature of a setter for this property: MethodSpec signature = buildSignature(domainClazz, config); if (signature != null) { // Add an abstract modifier to the signature: return signature.toBuilder() .addModifiers(Modifier.ABSTRACT) .addAnnotation(iriAnnotation) .build(); } else { return null; } } }
MethodSpec.Builder removerBuilder = signature.toBuilder();
COMPONENT_METHOD, methodSpec.toBuilder().addModifiers(FINAL).build()); } else {
unpackerBlock = unpackerBlock.toBuilder().endControlFlow().build(); pack = pack.toBuilder().addCode(packerBlock).build(); unpack = unpack.toBuilder().addCode(unpackerBlock).build(); pack = pack.toBuilder().nextControlFlow("catch ($T e)", NoSuchFieldException.class) .addStatement("throw new $T(e)",ClassName.get("com.nyrds.android.util","TrackedRuntimeException")) .nextControlFlow("catch ($T e)", IllegalAccessException.class) .endControlFlow().build(); unpack = unpack.toBuilder().nextControlFlow("catch ($T e)", NoSuchFieldException.class) .addStatement("throw new $T(e)",ClassName.get("com.nyrds.android.util","TrackedRuntimeException")) .nextControlFlow("catch ($T e)", IllegalAccessException.class)
MethodSpec.Builder adderBuilder = adder.toBuilder();
@Override MethodSpec buildSignature(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { if(getRanges() != null) { // Get the most specific class describing all of the properties range classes: BuildableRDFSClazz range = findSingleRangeClazz(); ClassName set = ClassName.get("java.util", "Set"); // Get the type of parameter type elements: TypeName setType = WildcardTypeName.subtypeOf(range.getJavaPoetClassName(config)); TypeName paramType = ParameterizedTypeName.get(set, setType); // Generate Javadoc if a rdfs:comment literal is available: CodeBlock.Builder javaDoc = CodeBlock.builder(); CharSequence preferredComment = getPreferredRDFSComment(config); if (preferredComment != null) { javaDoc.add(preferredComment.toString()); } javaDoc.add("\n@param values The elements to be removed."); javaDoc.add("\n@return Returns true if any value was removed."); return MethodNameBuilder.forObjectRepository(getObjectConnection()) .getJavaPoetMethodSpec("removeAll", this, config, true) .toBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(paramType, "values") .addJavadoc(javaDoc.build()) .returns(boolean.class) .build(); } else { return null; } }
MethodSpec.Builder removerAllBuilder = signature.toBuilder();
MethodSpec.Builder adderBuilder = signature.toBuilder();
@Override MethodSpec buildSignature(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { if(getRanges() != null) { // Get the most specific class describing all of the properties range classes: BuildableRDFSClazz range = findSingleRangeClazz(); ClassName set = ClassName.get("java.util", "Set"); // Get the type of parameter type elements: TypeName setType = WildcardTypeName.subtypeOf(range.getJavaPoetClassName(config)); TypeName paramType = ParameterizedTypeName.get(set, setType); // Generate Javadoc if a rdfs:comment literal is available: CodeBlock.Builder javaDoc = CodeBlock.builder(); CharSequence preferredComment = getPreferredRDFSComment(config); if (preferredComment != null) { javaDoc.add(preferredComment.toString()); } javaDoc.add("\n@param values The elements to be added."); // Add a throws declaration if the value space is constrained: addJavaDocExceptionInfo(javaDoc, range, config); return MethodNameBuilder.forObjectRepository(getObjectConnection()) .getJavaPoetMethodSpec("addAll", this, config, true) .toBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(paramType, "values") .addJavadoc(javaDoc.build()) .returns(void.class) .build(); } else { return null; } }
@Override MethodSpec buildSignature(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { if(getRanges() != null) { // Generate Javadoc if a rdfs:comment literal is available: CodeBlock.Builder javaDoc = CodeBlock.builder(); CharSequence preferredComment = getPreferredRDFSComment(config); if (preferredComment != null) { javaDoc.add(preferredComment.toString()); } javaDoc.add("\n@param value The element to be removed."); javaDoc.add("\n@return Returns true if the element was present. Returns false otherwise."); // Get the most specific class describing all of the properties range classes: BuildableRDFSClazz range = findSingleRangeClazz(); ClassName paramType = range.getJavaPoetClassName(config); return MethodNameBuilder.forObjectRepository(getObjectConnection()) .getJavaPoetMethodSpec("remove", this, config, false) .toBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(paramType, "value") .addJavadoc(javaDoc.build()) .returns(boolean.class) .build(); } else { return null; } }
@Override MethodSpec buildSignature(RDFSClazz domainClazz, OntGenerationConfig config) throws RepositoryException { if(getRanges() != null) { // Get the most specific class describing all of the properties range classes: ClassName paramType = getRangeJavaPoetClassName(config); // Generate Javadoc if a rdfs:comment literal is available: CodeBlock.Builder javaDoc = CodeBlock.builder(); CharSequence preferredComment = getPreferredRDFSComment(config); if (preferredComment != null) { javaDoc.add(preferredComment.toString()); } javaDoc.add("\n@param value The element to be added."); // Add a throws declaration if the value space is constrained: BuildableRDFSClazz range = findSingleRangeClazz(); addJavaDocExceptionInfo(javaDoc, range, config); return MethodNameBuilder.forObjectRepository(getObjectConnection()) .getJavaPoetMethodSpec("add", this, config, false) .toBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(paramType, "value") .addJavadoc(javaDoc.build()) .returns(void.class) .build(); } else { return null; } }
.toBuilder() .addModifiers(Modifier.PUBLIC) .returns(returnType)
.toBuilder() .addModifiers(Modifier.PUBLIC) .returns(void.class)