io.ultreia.java4all.bean.AbstractJavaBeanInstanceBuilder Maven / Gradle / Ivy
package io.ultreia.java4all.bean;
/*-
* #%L
* Java Beans extends by Ultreia.io
* %%
* Copyright (C) 2018 Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import io.ultreia.java4all.bean.definition.JavaBeanDefinition;
import io.ultreia.java4all.bean.definition.JavaBeanDefinitionStore;
/**
* Created by tchemit on 14/01/2018.
*
* @author Tony Chemit - [email protected]
*/
public class AbstractJavaBeanInstanceBuilder> implements JavaBeanInstanceBuilder {
private final JavaBeanDefinition javaBeanDefinition;
private final O result;
protected AbstractJavaBeanInstanceBuilder(JavaBeanDefinition javaBeanDefinition) {
this.javaBeanDefinition = javaBeanDefinition;
this.result = javaBeanDefinition.newInstance();
}
protected AbstractJavaBeanInstanceBuilder(Class extends JavaBeanDefinition> javaBeanDefinitionType) {
this(JavaBeanDefinitionStore.definition(javaBeanDefinitionType));
}
@SuppressWarnings("unchecked")
protected final P set(String propertyName, V value) {
javaBeanDefinition.set(propertyName, result, value);
return (P) this;
}
@Override
public final O build() {
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy