You now have a full set of implemented setter methods. Here's the code so far:
package curam.mypackage;
import java.util.Set;
import com.google.inject.Inject;
import curam.mypackage.struct.MyNewEntityDtls;
import curam.util.exception.InformationalException;
import
curam.util.persistence.helper.SingleTableLogicallyDeleteableEntityImpl;
import curam.util.type.Date;
import curam.util.type.DateRange;
import curam.util.type.StringHelper;
/**
* Standard implementation of {@linkplain MyNewEntity}.
*/
public class MyNewEntityImpl extends
SingleTableLogicallyDeleteableEntityImpl<MyNewEntityDtls>
implements MyNewEntity {
@Inject
private MyParentEntityDAO myParentEntityDAO;
@Inject
private MyChildEntityDAO myChildEntityDAO;
protected MyNewEntityImpl() {
/* Protected no-arg constructor for use only by Guice */
}
/*
* Field getters
*/
/**
* {@inheritDoc}
*/
public String getName() {
return getDtls().name;
}
/**
* {@inheritDoc}
*/
public DateRange getDateRange() {
return new DateRange(getDtls().startDate, getDtls().endDate);
}
/**
* {@inheritDoc}
*/
public MYNEWENTITYTYPEEntry getType() {
return MYNEWENTITYTYPEEntry.get(getDtls().typeCode);
}
/*
* Related-entity getters
*/
/**
* {@inheritDoc}
*/
public Set<MyChildEntity> getMyChildren() {
return myChildEntityDAO.searchByParent(this);
}
/**
* {@inheritDoc}
*/
public MyParentEntity getMyParentEntity() {
final long myParentEntityID = getDtls().myParentEntityID;
if (myParentEntityID == 0) {
return null;
} else {
return myParentEntityDAO.get(myParentEntityID);
}
}
/*
* Setters
*/
/**
* {@inheritDoc}
*/
public void setMyParentEntity(final MyParentEntity value) {
final long myParentEntityID;
if (value == null) {
myParentEntityID = 0;
} else {
myParentEntityID = value.getID();
}
getDtls().myParentEntityID = myParentEntityID;
}
/**
* {@inheritDoc}
*/
public void setName(final String value) {
getDtls().name = StringHelper.trim(value);
}
/**
* Sets the start and end fields from the date range supplied.
*
* @param value
* the date range supplied
*/
private void setDateRange(final DateRange value) {
getDtls().startDate = value.start();
getDtls().endDate = value.end();
}
/**
* {@inheritDoc}
*/
public void setType(final MYNEWENTITYTYPEEntry value) {
getDtls().typeCode = value.getCode();
}
/*
* Validation
*/
public void mandatoryFieldValidation() {
// TODO Auto-generated method stub
}
public void crossFieldValidation() {
// TODO Auto-generated method stub
}
public void crossEntityValidation() {
// TODO Auto-generated method stub
}
/**
* Defaults:
* <ul>
* <li>the type to {@linkplain MYNEWENTITYTYPEEntry#SOMETYPE};
* and</li>
* <li>the date range to {@linkplain DateRange#todayOnwards()}.
* </li>
* </ul>
*/
public void setNewInstanceDefaults() {
setType(MYNEWENTITYTYPEEntry.SOMETYPE);
setDateRange(DateRange.todayOnwards());
}
}