var c = new Customer(); c instanceof Customer; //Returns true as c is just a customer c instanceof String; //Returns false as c is not a string, it's a customer silly!
void initialize() {} void initData(Customer customer) { customerName.setText(customer.getName());
Customer customer = map.get(id); if(customer == null){ customer = new Customer(); customer.setId(id); customer.setName(rs.getString("CUSTOMER_NAME")); customer.setAccountNumber(rs.getLong("CUSTOMER_ACCOUNT_NO")); map.put(id, customer); List brandList = customer.getBrands(); if(brandsList == null) { brandsList = new ArrayList<Brand>(); customer.setBrands(brandsList); brandsList.add(brand); } else if(type == 0) { List ordersList = customer.getOrders(); if(ordersList == null) { ordersList = new ArrayList<Order>(); customer.setOrders(ordersList);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_top); Customer cust=new Customer(); cust.setName("abc"); cust.setCity("xyz"); Intent intent=new Intent(abc.this,xyz.class); intent.putExtra("bundle",cust); startActivity(intent); }
CouchbaseManager<String,Customer> cbmCustomer = new CouchbaseManager<String,Customer>(Customer.class); CouchbaseManager<String,Account> cbmAccount = new CouchbaseManager<String,Account>(Account.class); // and so on for other POJOs you have. // then get/put operations look simple Customer cust = cbmCustomer.get("cust-1234"); cust.setName("New Name"); // mutate value // store changes cbmCustomer.put(cust.getId(), cust);
import java.io.File; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(CustomerImpl.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); File xml = new File("input.xml"); Customer customer = (Customer) unmarshaller.unmarshal(xml); Address address = customer.getAddress(); System.out.println(address.getStreet()); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(customer, System.out); } }
EntityManager em = ...; EntityTransaction tx = em.getTransaction(); tx.begin(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); em.persist(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: em.flush(); em.clear(); } } tx.commit(); session.close();
Function<Customer, String> customerToName = new Function<Customer, String>() { public String apply(Customer c) { return c.getName(); }; List<String> allCustomerNamesList = Lists.transform(list, customerToName);
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Gson g = ...; String jsonString = g.toJson(new Customer());
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Customer customer = new Customer("Will");
for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } }
Object.prototype.CastToCustomer = function() { var c = new Customer(); if (document.URL.length) c = this; return c; }