Add retention policy to annotations
This commit is contained in:
parent
642044a15a
commit
d764e6c7b4
6 changed files with 20 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
|||
package dev.zontreck.ariaslib.json;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Serialization or Deserialization has completed.
|
||||
*
|
||||
|
@ -7,5 +10,6 @@ package dev.zontreck.ariaslib.json;
|
|||
*
|
||||
* Boolean: True for deserialization.
|
||||
*/
|
||||
@Retention ( RetentionPolicy.RUNTIME )
|
||||
public @interface Completed {
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package dev.zontreck.ariaslib.json;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Used on a class to indicate that it is serializable by the dynamic serializer.
|
||||
*/
|
||||
@Retention ( RetentionPolicy.RUNTIME )
|
||||
public @interface DynSerial {
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ public class DynamicDeserializer
|
|||
Field field :
|
||||
fields
|
||||
) {
|
||||
field.setAccessible ( true );
|
||||
|
||||
|
||||
if( !( field.getType ().isAnnotationPresent ( DynSerial.class ) ))
|
||||
{
|
||||
field.set ( object, map.get ( field.getName () ) );
|
||||
|
|
|
@ -45,6 +45,7 @@ public class DynamicSerializer {
|
|||
Field field :
|
||||
fields
|
||||
) {
|
||||
field.setAccessible ( true );
|
||||
if ( field.isAnnotationPresent ( IgnoreSerialization.class ) )
|
||||
continue;
|
||||
Object fieldVal = field.get ( inst );
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package dev.zontreck.ariaslib.json;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Marks an element to be ignored completely by the serializer or deserializer.
|
||||
*/
|
||||
@Retention ( RetentionPolicy.RUNTIME )
|
||||
public @interface IgnoreSerialization
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package dev.zontreck.ariaslib.json;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* To be set on a method, and will invoke that method prior to serialization beginning.
|
||||
*
|
||||
* Preparations should be made here
|
||||
*/
|
||||
@Retention ( RetentionPolicy.RUNTIME )
|
||||
public @interface PreSerialize {
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue