Created
November 27, 2012 15:51
-
-
Save jonpacker/4154993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.management.RuntimeErrorException; | |
public class ObjectAnalyzerObjecter { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
Object nonblockingObjectAnalyzer = new NonblockingObjectAnalyzer(512); | |
try { | |
((NonblockingObjectAnalyzer)nonblockingObjectAnalyzer).analyzeObject( | |
new NonblockingObjectAnalyzer.ObjectAnalyzer() { | |
@Override | |
public Object analyzeObject(Object object) { | |
return (Integer)object * 1024; | |
} | |
}); | |
} catch (NonblockingObjectAnalyzer erroneousNonblockingObjectAnalyzer) { | |
try { | |
erroneousNonblockingObjectAnalyzer.analyzeIfAnalyzedObjectIsAnalyzed(new NonblockingObjectAnalyzer.ObjectAnalyzedObject() { | |
@Override | |
public void objectAnalyzed(Object object, Object object2) { | |
System.out.printf("Hooray! %d * 1024 = %d!", object, object2); | |
} | |
}); | |
} catch (NonblockingObjectAnalyzer otherErroneousNonblockingObjectAnalyzer) { | |
throw new RuntimeErrorException(new Error(), ""); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Nonblocking Object Analyzer - analyzes objects without not nonblocking | |
* | |
* @author Jon D. Packer | |
* @version 6.0z Build 9001 Nov. 27 2012 | |
* @since 2012 | |
*/ | |
public class NonblockingObjectAnalyzer extends Throwable { | |
/** | |
* Serial version UID. The UID of the Serial Version. | |
*/ | |
private static final long serialVersionUID = 12846129561695L; | |
/** | |
* The object item (type Object) - the object to analyze | |
*/ | |
private Object object; | |
/** | |
* The other object item which indicates something. | |
*/ | |
private Object objectIsAnalyzedObject; | |
/** | |
* The result of analyzing an unanalyzed object. | |
*/ | |
private Object analyzedUnanalyzedObject; | |
/** | |
* Object Analyzed Object class, calls a method with an analyzed object after it has been | |
* analyzed with also the unanalyzed object before the analyzed object was analyzed. | |
*/ | |
public static abstract class ObjectAnalyzedObject { | |
/** | |
* Analyzed the Object | |
* | |
* @param object The object | |
* @param object2 The other object | |
*/ | |
public abstract void objectAnalyzed(Object object, Object object2); | |
} | |
/** | |
* Object Analyzer class - analyzes an object and returns an analyzed version of the preanalyzed | |
* object | |
*/ | |
public static abstract class ObjectAnalyzer { | |
/** | |
* Analyze the Object | |
* | |
* @param object The object | |
*/ | |
public abstract Object analyzeObject(Object object); | |
} | |
/** | |
* Constructor for NonblockingObjectAnalyzer. Constructs a NonblockingObjectAnalyzer by instantiating | |
* NonblockingObjectAnalyzer and setting Object object to Object object in this context. Is never not | |
* nonblocking. | |
* | |
* @param object The object | |
*/ | |
public NonblockingObjectAnalyzer(Object object) { | |
this.object = object; | |
} | |
/** | |
* Analyze the Object | |
* | |
* @param objectAnalyzer The object analyzer | |
* @param objectAnalyzedObject The analyzed object object | |
* @throws NonblockingObjectAnalyzer the erroneous nonblocking object analyzer. Most of the time it is this, but maybe not. | |
*/ | |
public void analyzeObject(Object object) throws NonblockingObjectAnalyzer { | |
Object analyzedObject = ((ObjectAnalyzer)object).analyzeObject(this.object); | |
objectIsAnalyzedObject = true; | |
analyzedUnanalyzedObject = analyzedObject; | |
throw this; | |
} | |
/** | |
* Analyze if analyzed object is analyzed | |
* | |
* @param object | |
* @throws NonblockingObjectAnalyzer | |
*/ | |
public void analyzeIfAnalyzedObjectIsAnalyzed(Object object) throws NonblockingObjectAnalyzer { | |
if ((Boolean)objectIsAnalyzedObject != true) throw this; | |
((ObjectAnalyzedObject)object).objectAnalyzed(this.object, analyzedUnanalyzedObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jon
wat r u doin
jon
stahp