Package com.niacin.persistence

Source Code of com.niacin.persistence.VariableInstanceCreator

package com.niacin.persistence;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import com.google.gson.InstanceCreator;
import com.niacin.input.IntegerVariable;
import com.niacin.input.Variable;

public class VariableInstanceCreator implements InstanceCreator<Variable<?>>
{
  @Override
  public Variable<?> createInstance(Type type)
  {
    Type[] typeParameters = ((ParameterizedType)type).getActualTypeArguments();
      Type idType = typeParameters[0];
      if(idType.equals(Integer.class))
        return new IntegerVariable();
    return null ;
  }

}
TOP

Related Classes of com.niacin.persistence.VariableInstanceCreator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.