class AnotherClass { public void someMethod() { One obj = new One(); obj.foo(); // This is perfectly valid. } }
function One() { this.x = 4; this.y = 'hhh'; } One.prototype.z = 'foobar'; var one = new One();
@Override public ZeroOrOne<NumericValue> resultWhenEmpty() { return new One<>(DoubleValue.NaN); }
/** * Convenience function to create a singleton boolean value * @param value the boolean value * @return the boolean value wrapped as a One<BooleanValue> */ public static One<BooleanValue> bool (boolean value) { return new One<>(BooleanValue.get(value)); }
public class Two { private final One aOne = new One(); Object getInTwo() { class InTwo extends One.InOne implements SomeInterface { public InTwo() { Two.this.aOne.super(); } public int someMethod() { return foo() + 100; } } return new InTwo(); } }
Map<String,CommonInterface> myMap = new HashMap<>(); myMap.put("one", new One()); myMap.put("two", new Two()); for (Map.Entry<String,CommonInterface> e : myMap.entrySet()) { System.out.println(e.getKey()); CommonInterface c = e.getValue(); c.commonMethod(123); }
/** * Convenience function to create a singleton boolean value * @param value the boolean value * @return the boolean value wrapped as a One<BooleanValue> */ public static One<BooleanValue> bool (boolean value) { return new One<>(BooleanValue.get(value)); }
public class Two { private final One aOne = new One(); Object getInTwo() { class InTwo extends One.InOne implements SomeInterface { public InTwo(){ aOne.super(); } public int someMethod() { return foo() + 100; } } return new InTwo(); } }
One one = new One(); Two two = new Two(); Object o1 = one; Object o2 = two; if (o1 instanceof One) { ... }
public class two { public static void main(String[] args){ One one=new One(); one.compute(); System.out.println(one.calculate()); } }
public class Two { public static void main(String[] args){ One one = new One(); one.compute(); System.out.println(one.calculate()); } }
/** * Convenience function to create a singleton double value * * @param value the double value * @return the double value wrapped as a One<DoubleValue> */ public static One<DoubleValue> dbl(double value) { return new One<>(new DoubleValue(value)); } }
/** * Convenience function to create a singleton integer value * @param value the integer value * @return the integer value wrapped as a One<IntegerValue> */ public static One<IntegerValue> integer (long value) { return new One<>(new Int64Value(value)); }
/** * Convenience function to create a singleton string value * @param value the string value * @return the boolean value wrapped as a One<StringValue> */ public static One<StringValue> string (String value) { return new One<>(new StringValue(value)); }
/** * Convenience function to create a singleton string value * @param value the string value * @return the boolean value wrapped as a One<StringValue> */ public static One<StringValue> string (String value) { return new One<>(new StringValue(value)); }
/** * Convenience function to create a singleton integer value * @param value the integer value * @return the integer value wrapped as a One<IntegerValue> */ public static One<IntegerValue> integer (long value) { return new One<>(new Int64Value(value)); }
/** * Convenience function to create a singleton double value * * @param value the double value * @return the double value wrapped as a One<DoubleValue> */ public static One<DoubleValue> dbl(double value) { return new One<>(new DoubleValue(value)); } }
@Override public ZeroOrOne<? extends AtomicValue> resultWhenEmpty() { return new One<>(new AnyURIValue("")); }
public static void main(String[] args) { One one = new One(); Two two = new Two(); one.setTwo(two); two.setOne(one); }