You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2007/10/29 11:20:43 UTC
svn commit: r589574 - in
/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata:
ClassDescriptor.java FieldDescriptor.java StateDetection.java
Author: arminw
Date: Mon Oct 29 03:20:42 2007
New Revision: 589574
URL: http://svn.apache.org/viewvc?rev=589574&view=rev
Log:
improve StateDetection
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/StateDetection.java
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java?rev=589574&r1=589573&r2=589574&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java Mon Oct 29 03:20:42 2007
@@ -2047,20 +2047,15 @@
}
/**
- * Returns the state detection status. Default state is <code>StateDetection.INHERIT</code>.
+ * Returns the state detection status. Default state is {@link StateDetection#INHERIT}.
+ * If mode {@link StateDetection#INHERIT} is set, this method resolves the
+ * mode of the higher level instance.
*
* @return The state detection status.
*/
public StateDetection getStateDetection()
{
- if(!stateDetection.isInherit())
- {
- return stateDetection;
- }
- else
- {
- return getRepository().getStateDetection();
- }
+ return stateDetection.isInherit() ? getRepository().getStateDetection() : stateDetection;
}
/**
@@ -2072,7 +2067,7 @@
*/
public void setStateDetection(String name)
{
- this.stateDetection = StateDetection.getEnum(name);
+ setStateDetection(StateDetection.getEnum(name));
}
/**
@@ -2084,6 +2079,10 @@
*/
public void setStateDetection(StateDetection stateDetection)
{
+ if(stateDetection == null)
+ {
+ throw new NullPointerException("Value can't be 'null'");
+ }
this.stateDetection = stateDetection;
}
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java?rev=589574&r1=589573&r2=589574&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java Mon Oct 29 03:20:42 2007
@@ -633,20 +633,15 @@
/**
* Returns whether or not this field should be included in
- * object state detection. Default state is <code>StateDetection.INHERIT</code>.
+ * object state detection. Default state is {@link StateDetection#INHERIT}.
+ * If mode {@link StateDetection#INHERIT} is set, this method resolves the
+ * mode of the higher level instance.
*
* @return The state detection status.
*/
public StateDetection getStateDetection()
{
- if(!stateDetection.isInherit())
- {
- return stateDetection;
- }
- else
- {
- return getClassDescriptor().getStateDetection();
- }
+ return stateDetection.isInherit() ? getClassDescriptor().getStateDetection() : stateDetection;
}
/**
@@ -658,7 +653,7 @@
*/
public void setStateDetection(String name)
{
- this.stateDetection = StateDetection.getEnum(name);
+ setStateDetection(StateDetection.getEnum(name));
}
/**
@@ -670,6 +665,10 @@
*/
public void setStateDetection(StateDetection stateDetection)
{
+ if(stateDetection == null)
+ {
+ throw new NullPointerException("Value can't be 'null'");
+ }
this.stateDetection = stateDetection;
}
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/StateDetection.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/StateDetection.java?rev=589574&r1=589573&r2=589574&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/StateDetection.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/StateDetection.java Mon Oct 29 03:20:42 2007
@@ -57,8 +57,7 @@
*/
public boolean isOn()
{
- // for best performance do simple comparison first
- return this == ON || !(this == OFF || this == INHERIT) && this.equals(ON);
+ return this == ON;
}
/**
@@ -67,8 +66,7 @@
*/
public boolean isOff()
{
- // for best performance do simple comparison first
- return this == OFF || !(this == ON || this == INHERIT) && this.equals(OFF);
+ return this == OFF;
}
/**
@@ -77,8 +75,7 @@
*/
public boolean isInherit()
{
- // for best performance do simple comparison first
- return this == INHERIT || !(this == OFF || this == ON) && this.equals(INHERIT);
+ return this == INHERIT;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org