debugging - Printing debug info on errors with java 8 lambda expressions -


I want to use a static method that is in the form of an effect, with the exception of the unsuccessful operation And the printing debug captures the information. I do not want the exception details only. I want to show how the property is being set up, so that I can work with Java 8 to help in debugging the issue in detail. I am

Should I establish or know the property?

I wish that the "name" string for example and get the same results.

I know that reflection can not be used based on the supplied method, which changes into lambda expression and then for BiConsumer.

I have received this but the property name is required.

  / ** Setter Assistant Method ** / Private Static & lt; E, V & gt; Zero set (eo, biconformer & lt; e, v> setter, supplier & lt; V & gt; value supplier, string property name) {{setter.accept (o, valueSupplier.get ()); } Hold (Runtime Execution E) {New Runtime Expansion ("Failed to set the value of" + propertyName, e); }}  

Example:

  person p = new person (); Supplier & LT; String & gt; NameSupplier1 = () - & gt; "my name"; Supplier & LT; String & gt; NameSupplier2 = () - & gt; {Throwing new runtime exceptions; }; Set (P, Person :: Setnam, Name Supplier 1, "Name"); Println (p.getName ()); // My name set print (p, person :: setname, name suppler 2, "name"); // throws an exception with the message failed to set the value of the name. System.out.println (p.getName ()); //  Edit   , But I want to know that there is a better way to do this with Java 8, which was not present with Java. It seems that I should. Now it is possible to do things like doing a  one setter system  to someone else.   

If you only expect method reference as a method, Can debug printable names:

  public static zero main (string [] args) {person p = new person (); Supplier & LT; String & gt; NameSupplier1 = () - & gt; "my name"; Supplier & LT; String & gt; NameSupplier2 = () - & gt; {Throwing new runtime exceptions; }; Set (P, Person :: Setnam, Name Supplier 1); Println (p.getName ()); // My name set print (p, person :: setname, name suplayer 2); // Exceptions with the message throws System.out.println (p.getName ()); // does not execute} interface debuggableBiConsumer & lt; A, B & gt; Private Static & lt; E, V & gt; BiConsumer & lt; A, B & gt; Zero set (eo, debuggable business & lt; e, v> setter, supplier & lt; v> price supplier) {{setter.accept (o, valueSupplier.get ()); } Hold (Runtime Execution E) {New Runtime Expansion ("" failed to set the name of "+ name (setter), e);}} Private static string name (DebuggableBiConsumer & lt;?,? & Gt; Setter) { For class ( 

There are limitations that this lambda expression (reference to synthetic method with lambda code) And the very useful method for "unknown property" will not print the context for custom implementation of the interface.


Comments