public void createState() { State state = new StateImpl(); state.setAbbreviation("KY"); state.setName("Kentucky"); state.setCountry(countryService.findCountryByAbbreviation("US")); stateService.save(state); }
/** * Returns the taxAmount for the passed in state or * null if no match is found. * * First checks the abbreviation (uppercase) followed by the name (uppercase). * * @param stateTaxRateMap, state * @return */ public Double lookupStateRate(Map<String,Double> stateTaxRateMap, State state) { if (stateTaxRateMap != null && state != null && state.getAbbreviation() != null) { String stateAbbr = state.getAbbreviation().toUpperCase(); Double rate = stateTaxRateMap.get(stateAbbr); if (rate == null && state.getName() != null) { String stateName = state.getName().toUpperCase(); return stateTaxRateMap.get(stateName); } else { return rate; } } return null; }
System.out.println("First Node is = "+firstNode); State firstState = new State(); firstState.setName("firstState"); System.out.println("First State is = "+ firstState); firstState.addArrivingTransition(t2); firstState.addLeavingTransition(t3); secondNode.addArrivingTransition(t3); secondNode.addLeavingTransition(t4);
spinner1.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { State state = (State) spinner1.getSelectedItem(); String stateId = state.getId(); String stateName = state.getName(); //you are very assured that the id matches the name selected and you can proceed from there } });
public class MyCustomAdapter extends ArrayAdapter<States> { public ArrayList<States> stateList; public MyCustomAdapter(Context context, int textViewResourceId, ArrayList<States> stateList) { super(context, textViewResourceId, stateList); this.stateList = new ArrayList<States>(); this.stateList.addAll(stateList); this.getSelectedList(); } private void getSelectedList() { pref = context.getSharedPreferences("MYPref", Context.MODE_PRIVATE); String text = pref.getString("key",""); List<String> selectedList = Arrays.asList(text.split(",")); for (State state: this.stateList) { if (selectedList.contains(state.getName())) { state.setSelected(true); } } } ... }
@DataProvider(name = "setupAddress") public static Object[][] createAddress() { Address address1 = new AddressImpl(); address1.setAddressLine1("1234 Merit Drive"); address1.setCity("Dallas"); State state = new StateImpl(); state.setAbbreviation("TX"); address1.setState(state); address1.setPostalCode("75251"); Address address2 = new AddressImpl(); address2.setAddressLine1("12 Testing Drive"); address2.setCity("San Jose"); state = new StateImpl(); state.setAbbreviation("CA"); address2.setState(state); address2.setPostalCode("75251"); return new Object[][] { new Object[] { address1 }, new Object[] { address2 } }; } }
@Entity @Table(name = "Businesses") public class Business{ //define id and other fields @ManyToOne @JoinColumn(name = "state_code") private State state; public String getStateName(){ return state.getName(); } } @Entity @Table(name="StateCodes") public class State{ //define id and other fields. @Column(name = "state_name") private String stateName; public String getStateName(){ return stateName; } }
state = address.getStateProvinceRegion(); } else if (address.getState() != null) { state = address.getState().getAbbreviation();
final JSONObject jsonObject = ... // ... final Iterable<Void> voids = Iterables.transform(Arrays.asList(states), new Function<State, Void>() { @Override public Void apply(State currentState) { jsonObject.put(String.valueOf(currentState.getId()), currentState.getName()); return null; } }); for ( final Void v : voids ) { // do nothing }
} else if (fgAddress.getState() != null) { stateAbbr = fgAddress.getState().getAbbreviation();
private Address buildAddress() { Address address = new AddressImpl(); address.setAddressLine1("123 Test Rd"); address.setCity("Dallas"); address.setFirstName("Jeff"); address.setLastName("Fischer"); address.setPostalCode("75240"); address.setPrimaryPhone("972-978-9067"); State state = new StateImpl(); state.setAbbreviation("ALL"); state.setName("ALL"); address.setState(state); Country country = new CountryImpl(); country.setAbbreviation("US"); country.setName("United States"); state.setCountry(country); address.setCountry(country); ISOCountry isoCountry = new ISOCountryImpl(); isoCountry.setAlpha2("US"); isoCountry.setName("UNITED STATES"); address.setIsoCountryAlpha2(isoCountry); return address; } }
} else if (billAddress.getState() != null) { stateAbbr = billAddress.getState().getAbbreviation();
state.setAbbreviation("TX"); state.setName("Texas"); state.setCountry(country);
state.setAbbreviation("TX"); state.setName("Texas"); state.setCountry(country);
state.setAbbreviation("TX"); state.setCountry(country); state.setName("Texas"); state2.setAbbreviation("TX"); state2.setCountry(country2); state2.setName("Texas");
state.setAbbreviation("TX"); state.setCountry(country); state.setName("Texas"); state2.setAbbreviation("TX"); state2.setCountry(country2); state2.setName("Texas");
state.setAbbreviation("TX"); state.setName("Texas"); state.setCountry(country);