src/main/java/org/beigesoft/replicator/service/SrvEntityFieldHasIdStringRepl.java
@Override
  public final void fill(final Map<String, Object> pAddParam,
    final Object pEntity, final String pFieldName,
      final String pFieldStrValue) throws Exception {
    Field rField = getUtlReflection().retrieveField(pEntity.getClass(),
      pFieldName);
    rField.setAccessible(true);
    if (!AHasIdString.class.isAssignableFrom(rField.getType())) {
      throw new ExceptionWithCode(ExceptionWithCode
        .CONFIGURATION_MISTAKE, "It's wrong service to fill that field: "
          + pEntity + "/" + pFieldName + "/" + pFieldStrValue);
    }
    if ("NULL".equals(pFieldStrValue)) {
      rField.set(pEntity, null);
      return;
    }
    try {
      @SuppressWarnings("unchecked")
      Constructor constructor = rField.getType().getDeclaredConstructor();
      Object ownedEntity = constructor.newInstance();
      ((AHasIdString) ownedEntity).setItsId(pFieldStrValue);
      rField.set(pEntity, ownedEntity);
    } catch (Exception ex) {
      throw new ExceptionWithCode(ExceptionWithCode
        .WRONG_PARAMETER, "Can not fill field: " + pEntity + "/" + pFieldName
          + "/" + pFieldStrValue + ", " + ex.getMessage(), ex);
    }
  }
@Override
  public final void fill(final Map<String, Object> pAddParam,
    final Object pEntity, final String pFieldName,
      final String pFieldStrValue) throws Exception {
    Field rField = getUtlReflection().retrieveField(pEntity.getClass(),
      pFieldName);
    rField.setAccessible(true);
    if (!AHasIdString.class.isAssignableFrom(rField.getType())) {
      throw new ExceptionWithCode(ExceptionWithCode
        .CONFIGURATION_MISTAKE, "It's wrong service to fill that field: "
          + pEntity + "/" + pFieldName + "/" + pFieldStrValue);
    }
    if ("NULL".equals(pFieldStrValue)) {
      rField.set(pEntity, null);
      return;
    }
    try {
      @SuppressWarnings("unchecked")
      Constructor constructor = rField.getType().getDeclaredConstructor();
      Object ownedEntity = constructor.newInstance();
      ((AHasIdString) ownedEntity).setItsId(pFieldStrValue);
      rField.set(pEntity, ownedEntity);
    } catch (Exception ex) {
      throw new ExceptionWithCode(ExceptionWithCode
        .WRONG_PARAMETER, "Can not fill field: " + pEntity + "/" + pFieldName
          + "/" + pFieldStrValue + ", " + ex.getMessage(), ex);
    }
  }
@ Override public final void fill ( final Map < String , Object > pAddParam , final Object pEntity , final String pFieldName , final String pFieldStrValue ) throws Exception { Field rField = getUtlReflection ( ) . retrieveField ( pEntity . getClass ( ) , pFieldName ) ; rField . setAccessible ( true ) ; if ( ! AHasIdString . class . isAssignableFrom ( rField . getType ( ) ) ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "It's wrong service to fill that field: " + pEntity + "/" + pFieldName + "/" + pFieldStrValue ) ; } if ( "NULL" . equals ( pFieldStrValue ) ) { rField . set ( pEntity , null ) ; return ; } try { @ SuppressWarnings ( "unchecked" ) Constructor constructor = rField . getType ( ) . getDeclaredConstructor ( ) ; Object ownedEntity = constructor . newInstance ( ) ; ( ( AHasIdString ) ownedEntity ) . setItsId ( pFieldStrValue ) ; rField . set ( pEntity , ownedEntity ) ; } catch ( Exception ex ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "Can not fill field: " + pEntity + "/" + pFieldName + "/" + pFieldStrValue + ", " + ex . getMessage ( ) , ex ) ; } }
<p>
Fill given field of given entity according value represented as
string.
</p>
@param pAddParam additional params
@param pEntity Entity.
@param pFieldName Field Name
@param pFieldStrValue Field value
@throws Exception - an exception
<p > Fill given field of given entity according value represented as string . < / p >