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?
18 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...
Dell Inspiron 600m battery
Dell Inspiron 8100 Battery
Dell Y9943 battery
Dell Inspiron 1521 battery
Dell Inspiron 510m battery
Dell Latitude D500 battery
Dell Latitude D520 battery
Dell GD761 battery
Dell NF343 battery
Dell D5318 battery
Dell G5260 battery
Dell Inspiron 9200 battery
Dell Latitude C500 battery
Dell HD438 Battery
Dell GK479 battery
Dell PC764 battery
Dell KD476 Battery
Dell Inspiron 1150 battery
Dell inspiron 8500 battery
Dell Inspiron 4100 battery
Dell Inspiron 4000 battery
Dell Inspiron 8200 battery
Dell FK890 battery
Dell Inspiron 1721 battery
Dell Inspiron 1300 Battery
Dell Inspiron 1520 Battery
Dell Latitude D600 Battery
Dell XPS M1330 battery
Dell Latitude D531N Battery
Dell INSPIRON 6000 battery
Dell INSPIRON 6400 Battery
Dell Inspiron 9300 battery
Other ways to unlock trapped cash thomas sabo is in the form of selling thomas sabo shop silverware, silver flatware, sterling silver thomas sabo jewellery and scrap silver. Each of these thomas sabo schmuck will fetch different values depending on charm club thomas sabo the product and purity factors. sabo charm club With the current economic condition, selling thomas sabo 2010 precious metals, either pure or scrap, has gained thomas sabo sales a lot of importance since it thomas sabo reduziert has great intrinsic value attached to it and selling the scrap is one of the smartest ways of making money.
I don't think these have made it into JDK7. Hopefully JDK8 will be blessed with these. Fingers crossed.
nice post thanks for sharing
appvn apk ios
tutuapp apk ios
Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care
http://rexapparels.com/boxer-manufacturers-in-tirupur-india/
http://rexapparels.com/track-pants-manufacturers-in-tirupur-india/
http://rexapparels.com/innerwear-manufacturers-in-tirupur-india/
http://rexapparels.com/buying-office-in-tirupur-india/
http://rexapparels.com/export-surplus-t-shirts-in-tirupur-india/
http://rexapparels.com/t-shirt-manufacturer-in-tirupur-india/
Post a Comment