The very quick overview of our recommendations:
- Static compare() methods for all non-void wrapper classes, not just Double and Float.
- Static hashCode() methods on all non-void wrapper classes.
- Integer.mod() and Long.mod()
- RoundingMode.round(double)
- Arrays.concat()
- EnumSet.complementOf(Collection)
- All JDK maps should implement putIfAbsent(), etc.
- Proxy.newProxyInstance(type, handler)
Please have a read over the document. What do you think about our proposals? What do you think we've missed?
16 comments:
I frequently need to add a single element to an array. Arrays.concat(T[], T) would be helpful. Arrays.concat(T[], T...) would be fine too. Arrays.concat(T[], new T[] { t }) would still be annoying.
This happens frequently when writing Eclipse IDE plug-ins
Whilst I think this list is a start, I don't think it goes far enough.
Commons lang and commons collections contains a whole wealth of ideas, as do similar utility projects elsewhere. My hope is that these methods won't be added to the JDK simply because they come from Google. I'd like to see a more rational process for determining what gets added and what doesn't.
And yes, that might mean a "Java 7 core libraries change JSR".
I don't think it goes far enough either, but it is NOT our intent to say "these are the ONLY library changes we want to let in." These happen to be the things that Doug and Josh and I were able to reach consensus on so far, so we put them in a document that bears our names; that's all.
You sent me some ideas in email; thanks for that (you should post them here too!)
+1
Great work, guys!
Are we going to have some of the Google Collections goodies too in Java 7 ? I think that will be great !
How about Enum.valueOf(int ordinal) method? Today, only Enum.valueOf(String name) method is generated by compiler. Enum.values() returns an array which result in a lot of boiler plate code in enum classes to support such method.
1) Trivial String test method in java.lang.String.
public static boolean isTrivial(String s)
A trivial string is either null or made of only whitespace.
2) Try parse methods for Numbers which don't throw NumberFormatException.
int Integer.tryParse(String s, int defaultValue)
int Integer.tryParse(String s, int redix, int defaultValue)
Would putIfAbsent use reference or value equality?
I think values since if reference it would be caught in most equals implementations.
I also have a suggestion.
How about 2 auxiliar methods like this:
/**
* Close closeables. Use this in a finally clause.
*/
public static void close(Closeable... closeables) {
for (Closeable c : closeables) {
if (c != null) {
try {
c.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
and
/**
* If possible reads an object, if not tries to instanciate the
* object with the given Callable. This allows lazy instantiation.
* If an exception occurs in the lazy instantiantion it returns null.
*/
public static T T readObject(String objectLocation, Callable t) {
ObjectInputStream s = null;
try {
s = new ObjectInputStream(new BufferedInputStream(new FileInputStream(objectLocation)));
return (T) s.readObject();
} catch (Exception ex) {
try {
return (T) t.call();
} catch (Exception e) {
e.printStackTrace();
}
} finally {
close(s);
}
return null;
}
What about calling the new Map intf MapEx or ExMap? Pretty descriptive of its nature and still a fairly compact name, IMHO.
If you're trying to add a method to the Map interface your extensions dovetail nicely with the proposed extension methods. Just a probably unneeded FYI.
I was pleasantly not surprised to see that you guys have a Join class in your collections API.
Man, it would be ~so~ nice if that were supported (somehow) by any object of type Collection or array. ..but it'd be a huge task to implement...
Why was there no follow on bankruptcy then? The bailout of AIG FP went to (wow power leveling) hedge funds that bound credit swaps on Lehman failing or others betting on rating (wow power leveling) declines. AIG has drained over 100 billion from the government. Which had to go to (wow power leveling) those who bet on failures and downgrades. Many of whom (power leveling)were hedge funds. I-banks that had offsetting swaps needed the money from the AIG bailout or they would have been caught. Its an (wow powerleveling) insiders game and it takes just a little bit too much time for most people to think (wow gold) through where the AIG 100 billion bailout money went to, hedge funds and players, many of whom hire from the top ranks of DOJ, Fed, Treasury, etc. ZHANG XIAO CHEN
cheap wedding gowns,
discount bridal gowns,
China wedding dresses,
discount designer wedding dresses,
China wedding online store,
plus size wedding dresses,
cheap informal wedding dresses,
junior bridesmaid dresses,
cheap bridesmaid dresses,
maternity bridesmaid dresses,
discount flower girl gowns,
cheap prom dresses,
party dresses,
evening dresses,
mother of the bride dresses,
special occasion dresses,
cheap quinceanera dresses,
hot red wedding dresses
nike shoes, jordan shoes, nike dunks, nike air force 1, nike shox, nike shoes, nike shox, nike dunks, nike air force 1, nike shox, nike shoes, nike shox oz, nike shox nz, nike shox r3, nike shox r4, nike shox r5, nike shox tl
nike air force 1
nike Air Force 1, nike shoes, Jordan shoes, nike sb dunks, cheap nike Air Force 1, cheap nike shoes, cheap Jordan shoes, cheap nike sb dunks, discount nike Air Force 1, discount nike shoes, discount Jordan shoes, discount nike sb dunks, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes
nike shoes, nike shox, jordan shoes, puma shoes, nike dunks, nike air max, nike air force one, timberland boots, ugg boots, nike shoes, nike shox, nike air force 1, nike sb dunks, puma shoes, nike air max, jordan shoes, ugg boot, jordan sneakers, timberland shoes, bape shoes, nike shoes, nike shox, nike dunks, nike air force 1, jordan shoes
Post a Comment