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

com.javaetmoi.javabean.bean.SetterParam Maven / Gradle / Ivy

Go to download

The JavaBeanMarshaller class is responsible for serializing an object (graph) to it's Java code.

There is a newer version: 1.0.3
Show newest version
package com.javaetmoi.javabean.bean;


import com.javaetmoi.javabean.JavaBeanMarshaller;
import com.squareup.javapoet.TypeSpec;

import java.beans.PropertyDescriptor;

/**
 * Set of parameters used to generate a "setter" (ie. mutator) statement.
 *
 * 

* This structure could also be used to add an object into a collection, an array or a map. *

*/ public class SetterParam { private final String varName; private final PropertyDescriptor propertyDescriptor; private final Object value; private final String setterName; private final Class valueClass; private final JavaBeanMarshaller marshaller; public SetterParam(JavaBeanMarshaller marshaller, String varName, PropertyDescriptor propertyDescriptor, Object value, String setterName) { this.marshaller = marshaller; this.varName = varName; this.propertyDescriptor = propertyDescriptor; this.value = value; this.setterName = setterName; this.valueClass = value.getClass(); } /** * * @return current object instance variable the setter belongs to. */ public String getVarName() { return varName; } /** * * @return property descriptor (may be null for the root object of the graph). */ public PropertyDescriptor getPropertyDescriptor() { return propertyDescriptor; } /** * @return object to pass as a parameter to the setter. */ public Object getValue() { return value; } /** * @return name of the mutator (setXXXX, add, put) called by the Java statement. */ public String getSetterName() { return setterName; } public Class getValueClass() { return valueClass; } /** * @return Javapoet's class builder where utility method could be added. */ public TypeSpec.Builder getCurrentClass() { return marshaller.getClazz(); } /** * @return instance of the current Java marshaller */ public JavaBeanMarshaller getMarshaller() { return marshaller; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy