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