All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jsonex.jsoncoder.coder.CoderAtomicInteger Maven / Gradle / Ivy

There is a newer version: 0.1.27
Show newest version
/*************************************************************
 Copyright 2018-2019 eBay Inc.
 Author/Developer: Jianwu Chen

 Use of this source code is governed by an MIT-style
 license that can be found in the LICENSE file or at
 https://opensource.org/licenses/MIT.
 ************************************************************/

package org.jsonex.jsoncoder.coder;

import org.jsonex.core.factory.InjectableInstance;
import org.jsonex.jsoncoder.BeanCoderContext;
import org.jsonex.jsoncoder.ICoder;
import org.jsonex.treedoc.TDNode;

import java.lang.reflect.Type;
import java.util.concurrent.atomic.AtomicInteger;

public class CoderAtomicInteger implements ICoder {
  public static final InjectableInstance it = InjectableInstance.of(CoderAtomicInteger.class);
  public static CoderAtomicInteger get() { return it.get(); }

  @Override public Class getType() {return AtomicInteger.class;}
  
  @Override public TDNode encode(AtomicInteger obj, Type type, BeanCoderContext context, TDNode target) { return target.setValue(obj.get()); }

  @Override public AtomicInteger decode(TDNode tdNode, Type type, Object targetObj, BeanCoderContext context) {
    return new AtomicInteger((int)tdNode.getValue());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy