JBND Client-Side _Entity.java Template

Version 2.1 by David Avendasora on 2008/03/06 15:30

This template requires the JBND library or source code be included on the Client-Side of the application.


// <$GEN_PREFIX$><$classNameWithoutPackage$>.java
//
// Created by eogenerator
//
// DO NOT EDIT.  Make changes to <$classNameWithoutPackage$>.java instead.
//
// This EO was generated to perform standard JBND behaviors
// 1. All setter methods will not set new values if they are identical to old values.
// 2. All setter methods invoke EOFDataObject.fireDataObjectEvent(String key, Object oldValue).
// 3. All attribute and relationship keys are stored as static final Strings.
// 4. A default constructor is provided to automatically call the superclass constructor
// that accepts an EOClassDescription argument, used to avoid bugs in the client side EOF.

#if ($entity.superclassPackageName)
package $entity.superclassPackageName;

#end

import com.webobjects.foundation.*;
import com.webobjects.eocontrol.*;
import java.math.BigDecimal;
import java.util.*;
import org.jbnd.support.Utilities;
import org.jbnd.eof.EOFDataObject;

/**
* Abstract Enterprise object class, representing a "<$name$>" record, defining all getter and
* setter methods for client side attributes and relationship. Generated with EOGenerator
* to fire object change evens, according to JBND requirements.
*/
@SuppressWarnings("all")
public abstract class ${entity.prefixClassNameWithoutPackage} extends #if ($entity.parentSet)${entity.parent.classNameWithDefault}#elseif ($EOGenericRecord)${EOGenericRecord}#else EOFDataObject#end {

/** Entity name of the EO. */
public static final String ENTITY_NAME = "$entity.name";

/** Attribute keys */
#foreach ($attribute in $entity.sortedClassAttributes)
#if ($attribute.clientClassProperty)
public static final String ${attribute.uppercaseUnderscoreName}_KEY = "$attribute.name";
#end
#end

/** To-one relationship keys */
#foreach ($relationship in $entity.sortedClassRelationships)
#if ($relationship.clientClassProperty)
public static final String ${relationship.uppercaseUnderscoreName}_KEY = "$relationship.name";
#end
#end


/**
* Constructor. Creates an EO with the <tt>EOClassDescription</tt> of the
* relevant entity, to ensure a proper client side behavior.
*/
public ${entity.prefixClassNameWithoutPackage}() {
super(EOClassDescription.classDescriptionForEntityName("$entity.name"));
}

#foreach ($attribute in $entity.sortedClassAttributes)
#if (!$attribute.inherited)
#if ($attribute.clientClassProperty)
public $attribute.javaClassName ${attribute.name}() {
return ($attribute.javaClassName) storedValueForKey(${attribute.uppercaseUnderscoreName}_KEY);
}

public void set${attribute.capitalizedName}($attribute.javaClassName aValue) {
// extract old value
$attribute.javaClassName oldValue = ${attribute.name}();

// do not perform EOF work unless values are different
if(Utilities.equals(oldValue, aValue)) return;

takeStoredValueForKey(aValue, ${attribute.uppercaseUnderscoreName}_KEY);
fireDataObjectEvent(${attribute.uppercaseUnderscoreName}_KEY, oldValue);
}
#end
#end
#end

#foreach ($relationship in $entity.sortedClassToOneRelationships)
#if (!$relationship.inherited) 
#if ($relationship.clientClassProperty)
public $relationship.actualDestination.classNameWithDefault ${relationship.name}() {
return ($relationship.actualDestination.classNameWithDefault) storedValueForKey(${relationship.uppercaseUnderscoreName}_KEY);
}

public void set${relationship.capitalizedName}($relationship.actualDestination.classNameWithDefault aValue) {
// get old value
$relationship.actualDestination.classNameWithDefault oldValue = ${relationship.name}();

// do not perform EOF work unless values are different
if(Utilities.equals(oldValue, aValue)) return;

takeStoredValueForKey(aValue, ${relationship.uppercaseUnderscoreName}_KEY);
fireDataObjectEvent(${relationship.uppercaseUnderscoreName}_KEY, oldValue);
}
#end
#end
#end

#foreach ($relationship in $entity.sortedClassToManyRelationships)
#if (!$relationship.inherited) 
#if ($relationship.clientClassProperty)
public NSArray<${relationship.actualDestination.classNameWithDefault}> ${relationship.name}() {
return (NSArray<${relationship.actualDestination.classNameWithDefault}>)storedValueForKey(${relationship.uppercaseUnderscoreName}_KEY);
}

public void set${relationship.capitalizedName}(NSArray<${relationship.actualDestination.classNameWithDefault}> aValue) {
Object oldValue = ${relationship.name}();
takeStoredValueForKey(aValue, ${relationship.uppercaseUnderscoreName}_KEY);
fireDataObjectEvent(${relationship.uppercaseUnderscoreName}_KEY, oldValue);
}

public void addTo${relationship.capitalizedName}(${relationship.actualDestination.classNameWithDefault} object) {
Object oldValue = ${relationship.name}();
includeObjectIntoPropertyWithKey(object, ${relationship.uppercaseUnderscoreName}_KEY);
fireDataObjectEvent(${relationship.uppercaseUnderscoreName}_KEY, oldValue);
}

public void removeFrom${relationship.capitalizedName}(${relationship.actualDestination.classNameWithDefault} object) {
Object oldValue = ${relationship.name}();
excludeObjectFromPropertyWithKey(object, ${relationship.uppercaseUnderscoreName}_KEY);
fireDataObjectEvent(${relationship.uppercaseUnderscoreName}_KEY, oldValue);
}
#end
#end
#end
}