net.sf.mmm.util.pojo.base.PojoUtilImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mmm-util-pojo Show documentation
Show all versions of mmm-util-pojo Show documentation
This project provides common utitlities to for POJOs.
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.util.pojo.base;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import net.sf.mmm.util.collection.base.HashKey;
import net.sf.mmm.util.component.base.AbstractLoggableComponent;
import net.sf.mmm.util.filter.api.Filter;
import net.sf.mmm.util.pojo.api.PojoUtil;
import net.sf.mmm.util.pojo.descriptor.api.PojoDescriptor;
import net.sf.mmm.util.pojo.descriptor.api.PojoDescriptorBuilder;
import net.sf.mmm.util.pojo.descriptor.api.PojoDescriptorBuilderFactory;
import net.sf.mmm.util.pojo.descriptor.api.PojoPropertyDescriptor;
import net.sf.mmm.util.pojo.descriptor.api.accessor.PojoPropertyAccessorNonArg;
import net.sf.mmm.util.pojo.descriptor.api.accessor.PojoPropertyAccessorNonArgMode;
import net.sf.mmm.util.pojo.descriptor.impl.PojoDescriptorBuilderFactoryImpl;
/**
* This class is a collection of utility functions for dealing with {@link java.lang.reflect reflection}.
*
* @see #getInstance()
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 7.1.0
*/
public class PojoUtilImpl extends AbstractLoggableComponent implements PojoUtil {
private static PojoUtil instance;
private PojoDescriptorBuilderFactory pojoDescriptorBuilderFactory;
private PojoDescriptorBuilder pojoDescriptorBuilder;
/**
* The constructor.
*/
public PojoUtilImpl() {
super();
}
/**
* This method gets the singleton instance of this {@link PojoUtil}.
* ATTENTION:
* Please read {@link net.sf.mmm.util.component.api.Cdi#GET_INSTANCE} before using.
*
* @return the singleton instance.
*/
public static PojoUtil getInstance() {
if (instance == null) {
PojoUtilImpl impl = null;
synchronized (PojoUtilImpl.class) {
if (instance == null) {
impl = new PojoUtilImpl();
impl.initialize();
instance = impl;
}
}
}
return instance;
}
@Override
protected void doInitialized() {
super.doInitialized();
if (instance == null) {
instance = this;
}
}
@Override
protected void doInitialize() {
super.doInitialize();
if (this.pojoDescriptorBuilderFactory == null) {
this.pojoDescriptorBuilderFactory = PojoDescriptorBuilderFactoryImpl.getInstance();
}
if (this.pojoDescriptorBuilder == null) {
this.pojoDescriptorBuilder = this.pojoDescriptorBuilderFactory.createPrivateFieldDescriptorBuilder();
}
}
/**
* @return the instance of {@link PojoDescriptorBuilderFactory}.
*/
protected PojoDescriptorBuilderFactory getPojoDescriptorBuilderFactory() {
return this.pojoDescriptorBuilderFactory;
}
/**
* @param pojoDescriptorBuilderFactory is the instance of {@link PojoDescriptorBuilderFactory} to
* {@link Inject}.
*/
@Inject
public void setPojoDescriptorBuilderFactory(PojoDescriptorBuilderFactory pojoDescriptorBuilderFactory) {
getInitializationState().requireNotInitilized();
this.pojoDescriptorBuilderFactory = pojoDescriptorBuilderFactory;
}
/**
* @return the {@link PojoDescriptorBuilder}.
*/
protected PojoDescriptorBuilder getPojoDescriptorBuilder() {
return this.pojoDescriptorBuilder;
}
/**
* @param pojoDescriptorBuilder is the {@link PojoDescriptorBuilder} to set.
*/
public void setPojoDescriptorBuilder(PojoDescriptorBuilder pojoDescriptorBuilder) {
this.pojoDescriptorBuilder = pojoDescriptorBuilder;
}
@Override
public void visitObjectRecursive(Object object, Filter
© 2015 - 2024 Weber Informatics LLC | Privacy Policy