Example usage for org.springframework.beans BeanUtils copyProperties

List of usage examples for org.springframework.beans BeanUtils copyProperties

Introduction

In this page you can find the example usage for org.springframework.beans BeanUtils copyProperties.

Prototype

public static void copyProperties(Object source, Object target, String... ignoreProperties)
        throws BeansException 

Source Link

Document

Copy the property values of the given source bean into the given target bean, ignoring the given "ignoreProperties".

Usage

From source file:com.companyname.extension.PlatAuthentication.java

public static Authentication getPlatAuthentication(Authentication authentication) {

    if (authentication == null) {
        return null;
    }// ww  w.j  a  v a  2 s. c  o m

    PlatAuthentication auth = new PlatAuthentication(authentication.getPrincipal(),
            authentication.getCredentials(), authentication.getAuthorities());

    BeanUtils.copyProperties(authentication, auth, new String[] { "authenticated" });

    return auth;
}

From source file:org.nekorp.workflow.desktop.servicio.bridge.PagoCobranzaBridge.java

@Override
public void load(PagoCobranza origen, PagoCobranzaVB destino) {
    BeanUtils.copyProperties(origen, destino, "monto");
    destino.setMonto(MonedaVB.valueOf(origen.getMonto().getValue()));
}

From source file:org.nekorp.workflow.desktop.servicio.bridge.AutoBridge.java

@Override
public void load(Auto origen, AutoVB destino) {
    BeanUtils.copyProperties(origen, destino, new String[] { "equipamiento" });
    equipamientoBridge.load(origen.getEquipamiento(), destino.getEquipamiento());

}

From source file:org.nekorp.workflow.desktop.servicio.bridge.DamageDetailBridge.java

@Override
public void load(DamageDetail origen, DamageDetailsVB destino) {
    BeanUtils.copyProperties(origen, destino, new String[] { "id", "esquema" });
    if (origen.getId() != null) {
        destino.setId(origen.getId().toString());
    } else {//www .j  a v  a 2 s .  c  o m
        destino.setId("");
    }
}

From source file:com.jinmibao.common.util.BeanUtil.java

/**
 * ? ????? ?//from   w  ww.  j ava  2  s  .com
 * 
 * @param source
 * @param target
 */
public static void copyPropertiesIfNull(Object source, Object target) {
    if (source == null || target == null) {
        throw new RuntimeException("Source Or Target Can't Be Null");
    }
    Method[] methods = target.getClass().getDeclaredMethods();
    List<String> notNullPropertyList = new ArrayList<String>();
    for (Method method : methods) {
        if (!method.getName().startsWith("get")) {
            continue;
        }
        try {
            Object methodResult = method.invoke(target);
            if (methodResult != null) {
                if (method.getReturnType().getName().equals("java.lang.String")
                        && StringUtil.isBlank((String) methodResult)) {
                    continue;
                }
                notNullPropertyList.add(BeanUtils.findPropertyForMethod(method).getName());
            }
        } catch (Exception e) {
            logger.error("", e);
        }
    }
    BeanUtils.copyProperties(source, target, ListUtil.list2Array(notNullPropertyList));
}

From source file:org.nekorp.workflow.desktop.servicio.bridge.RegistroCostoBridge.java

@Override
public void load(RegistroCosto origen, RegistroCostoVB destino) {
    BeanUtils.copyProperties(origen, destino, new String[] { "id", "tipo", "precioUnitario", "precioCliente" });
    if (origen.getId() != null) {
        destino.setId(origen.getId().toString());
    } else {//w  w w  .  j a v a2s . c om
        destino.setId("");
    }
    destino.setPrecioUnitario(MonedaVB.valueOf(origen.getPrecioUnitario().getValue()));
    destino.setPrecioCliente(MonedaVB.valueOf(origen.getPrecioCliente().getValue()));
}

From source file:org.nekorp.workflow.desktop.servicio.bridge.EquipamientoBridge.java

@Override
public void load(Equipamiento origen, EquipamientoVB destino) {
    BeanUtils.copyProperties(origen, destino, new String[] { "transmision", "elevadores" });
    destino.setTransmision(/*from   w  w w . ja  v  a  2s . co  m*/
            TipoTransmisionVB.valueOf(StringUtils.defaultIfEmpty(origen.getTransmision(), "estandar")));
    destino.setElevadores(
            TipoElevadorVB.valueOf(StringUtils.defaultIfEmpty(origen.getElevadores(), "manuales")));
}

From source file:org.nekorp.workflow.desktop.servicio.bridge.ClienteBridge.java

@Override
public void load(Cliente origen, ClienteVB destino) {
    BeanUtils.copyProperties(origen, destino, new String[] { "id", "domicilio", "telefonoContacto" });
    if (origen.getId() != null) {
        destino.setId(origen.getId().toString());
    } else {//w  w  w  .  jav  a2 s .  c  om
        destino.setId("");
    }
    domicilioBridge.load(origen.getDomicilio(), destino.getDomicilio());
    telefonoBridge.load(origen.getTelefonoContacto().get(0), destino.getTelefonoUno());
    telefonoBridge.load(origen.getTelefonoContacto().get(1), destino.getTelefonoDos());
    telefonoBridge.load(origen.getTelefonoContacto().get(2), destino.getTelefonoTres());
}

From source file:org.syncope.core.rest.data.NotificationDataBinder.java

public NotificationTO getNotificationTO(final Notification notification) {
    NotificationTO result = new NotificationTO();

    BeanUtils.copyProperties(notification, result, IGNORE_PROPERTIES);

    result.setId(notification.getId());//from   www . j av  a 2  s  .c om
    result.setAbout(notification.getAbout());
    result.setRecipients(notification.getRecipients());

    return result;
}

From source file:org.nekorp.workflow.desktop.servicio.bridge.DatosAutoBridge.java

@Override
public void unload(DatosAutoVB origen, DatosAuto destino) {
    BeanUtils.copyProperties(origen, destino, new String[] { "damage" });
    destino.setCombustible(StringUtils.defaultIfEmpty(origen.getCombustible(), "0"));
}