Closed konsultaner closed 6 years ago
I solved the problem by extending velocy packs VPackJdk8Module to also support another annotation. It may help others:
package de.konsultaner.velocypack;
import com.arangodb.velocypack.VPackAnnotationFieldFilter;
import com.arangodb.velocypack.VPackSetupContext;
public class VPackJdk8Module extends com.arangodb.velocypack.module.jdk8.VPackJdk8Module {
@Override
public <C extends VPackSetupContext<C>> void setup(C context) {
super.setup(context);
context.annotationFieldFilter(VExpose.class, new VPackAnnotationFieldFilter<VExpose>() {
@Override
public boolean serialize(final VExpose annotation) {
return annotation.serialize();
}
@Override
public boolean deserialize(final VExpose annotation) {
return annotation.deserialize();
}
});
}
}
and
package de.konsultaner.velocypack;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface VExpose {
boolean serialize() default true;
boolean deserialize() default true;
}
I can now use it like this:
@VExpose(serialize = false)
public String myField
I use boon in a project that also uses arangoDB. My models are stored to the database where I hide fields with
boon serializes this model to send it to another client. The problem now is that I actually use the
Expose
annotation from velocity pack that has the same structure as the boon one. Boon does not type check the annotation. Thats why it does not serializemyField
eventhough it is not ment to be.