/** * Create a new Example criterion instance, which includes all non-null properties by default * * @param exampleEntity The example bean to use. * * @return a new instance of Example */ public static Example create(Object exampleEntity) { if ( exampleEntity == null ) { throw new NullPointerException( "null example entity" ); } return new Example( exampleEntity, NotNullPropertySelector.INSTANCE ); }
function Emitter() { var eventTarget = document.createDocumentFragment() function delegate(method) { this[method] = eventTarget[method].bind(eventTarget) } [ "addEventListener", "dispatchEvent", "removeEventListener" ].forEach(delegate, this) } // sample class to use it function Example() { Emitter.call(this) } // run it var e = new Example() e.addEventListener("something", function(event) { console.log(event) }) e.dispatchEvent(new Event("something"))
public class ExampleProvider implements Provider<Example> { @AOPExample public Example get() { System.out.println("Building..."); return new Example(); } }
public class MyMainClass { public static void main(final String[] args) { final MyMainClass clazz = new MyMainClass(); clazz.echo(new Example()); } public Example echo(@Valid final Example example) { // ... } }
function Example() { var someVar = something; var moreState = initializedToSomethingElse; this.verifySomething(); // <== Works } Example.prototype.verifySomething = function() { // do verify stuff }; var e = new Example();
import foo.*: import bar.*: class MyClass { void someMethod() { // Assume that this class is from the "foo" librariy, and the // fully qualified name of this class is "foo.Example" Example e = new Example(); } }
var Example = (function() { function Example() { var someVar = something; var moreState = initializedToSomethingElse; this.verifySomething(); // <== Works } Example.prototype.verifySomething = function() { // do verify stuff }; return Example; })(); var e = new Example();
(function() { var problem = new Example(); $("#sign").change(problem.newSign.bind(problem)); $(".number").change(problem.newNumber.bind(problem)); })();
package CallBefore; public class Main { public static void main(String[] args) { ExampleInterface proxy = ExampleProxy.newInstance(new Example()); proxy.function1(); proxy.function2(); proxy.otherFunction(); proxy.refresh(); } }
var Example = function () { this.prop1 = "test1"; this.prop2 = "test2" }; var newObj2 = new Example();
import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; Fragment fragment= new Example(); FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.main_fragment, fragment, fragment.getClass().getName()); ft.addToBackStack(fragment.getClass().getName()); ft.commit();
/** * Create a new instance, which includes all non-null properties * by default * @param entity * @return a new instance of <tt>Example</tt> */ public static Example create(Object entity) { if (entity==null) throw new NullPointerException("null example"); return new Example(entity, NOT_NULL); }
/** * Create a new instance, which includes all non-null properties * by default * @param entity * @return a new instance of <tt>Example</tt> */ public static Example create(Object entity) { if (entity==null) throw new NullPointerException("null example"); return new Example(entity, NOT_NULL); }
Example ee=new Example(); FileInputStream in=new FileInputStream("hyxa_code.txt"); ObjectInputStream o=new ObjectInputStream(in); ee=(Example)o.readObject(); System.out.println("The vlaue of i,j:"+ee.i+" "+ee.j);
GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Example.class, new ExampleTypeAdapter()); gsonBuilder.setPrettyPrinting(); Gson gson = gsonBuilder.create(); Example example = new Example(); example.title = "mytitle"; example.id = 1234; example.userId = 0; final String json = gson.toJson(example); System.out.println(json);
@Test public void testMethod() { int something = 0; Foo mockFoo = mock(Foo.class, RETURNS_DEEP_STUBS); when(mockFoo.doSomething()).thenReturn(something); assertEquals(new Example().method(mockFoo), something); verify(mockFoo); }
public static void main(String[] args) { Example sharedData = new Example(); for (int i = 0; i < 1000; i++) sharedData.increment(); System.out.println("Incrementer finished"); for (int i = 0; i < 1000; i++) sharedData.decrement(); System.out.println("Decrementer finished"); System.out.println(sharedData.count); }
Example e = new Example(); // do lots of stuff e.setId(12345L); e.build(); // at this point, e is immutable