You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sentry.apache.org by Brian Towles <bt...@cloudera.com> on 2018/05/24 19:54:47 UTC

Thoughts on using lombok?

Howdy all,

I was wondering what the teams thoughts are on using Lombok?

https://projectlombok.org/

Lombok is a tool that uses annotations at *compile time* to dynamically
generate the boilerplate code for things like getters, setters, basic
constructors, toString, equals, etc...
There are no actual code changes to the source, so its not a traditional
generator.  It uses the internal
To me it has been a very helpful time saver for coding and maintenance and
it allows for us to avoid missing things.

A good look at how it works in IntelliJ and Eclipse is here:
https://www.javacodegeeks.com/2016/06/lombok-compile-time-java-annotation-preprocessor-minimize-code-size.html

But as a quick example of using this for a very simple class and a single
@Data annotation takes:

package org.apache.sentry;

import lombok.Data;

@Data
public class SimpleBean {
  private final String name;
  private int age;
  private double score;
  private String[] tags;
}

and turn it effectively into

package org.apache.sentry;

public class SimpleBean {
  private final String name;
  private int age;
  private double score;
  private String[] tags;

  @java.beans.ConstructorProperties({"name"})
  public SimpleBean(String name) {
    this.name = name;
  }

  public String getName() {
    return this.name;
  }

  public int getAge() {
    return this.age;
  }

  public double getScore() {
    return this.score;
  }

  public String[] getTags() {
    return this.tags;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public void setScore(double score) {
    this.score = score;
  }

  public void setTags(String[] tags) {
    this.tags = tags;
  }

  public boolean equals(Object o) {
    if (o == this) {
      return true;
    }
    if (!(o instanceof SimpleBean)) {
      return false;
    }
    final SimpleBean other = (SimpleBean) o;
    if (!other.canEqual((Object) this)) {
      return false;
    }
    final Object this$name = this.getName();
    final Object other$name = other.getName();
    if (this$name == null ? other$name != null :
!this$name.equals(other$name)) {
      return false;
    }
    if (this.getAge() != other.getAge()) {
      return false;
    }
    if (Double.compare(this.getScore(), other.getScore()) != 0) {
      return false;
    }
    if (!java.util.Arrays.deepEquals(this.getTags(), other.getTags())) {
      return false;
    }
    return true;
  }

  public int hashCode() {
    final int PRIME = 59;
    int result = 1;
    final Object $name = this.getName();
    result = result * PRIME + ($name == null ? 43 : $name.hashCode());
    result = result * PRIME + this.getAge();
    final long $score = Double.doubleToLongBits(this.getScore());
    result = result * PRIME + (int) ($score >>> 32 ^ $score);
    result = result * PRIME + java.util.Arrays.deepHashCode(this.getTags());
    return result;
  }

  protected boolean canEqual(Object other) {
    return other instanceof SimpleBean;
  }

  public String toString() {
    return "SimpleBean(name=" + this.getName() + ", age=" +
this.getAge() + ", score=" + this
        .getScore() + ", tags=" +
java.util.Arrays.deepToString(this.getTags()) + ")";
  }
}


There are more helper functions in the library for things like Builders,
and Synchronized.

What do you guys think about using this in Sentry?

-=Brian

-- 
*Brian Towles* | Software Engineer
t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <jo...@cloudera.com>
cloudera.com <http://www.cloudera.com/>

[image: Cloudera] <http://www.cloudera.com/>

[image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
on LinkedIn] <https://www.linkedin.com/company/cloudera>
------------------------------

Re: Thoughts on using lombok?

Posted by Brian Towles <bt...@cloudera.com>.
The lombok plugin for IntelliJ has all of that built in.  You select find
usage of on the variable and it will show the usage of the getters and
setters.  From what I have seen the eclipse plugin has that as well.

-=Brian

On Fri, May 25, 2018 at 12:28 PM Alexander Kolbasov <ak...@cloudera.com>
wrote:

> Brian,
>
> This seems interesting. How does it interplay with IntelliJ/Eclipse
> ability to find all usages of the method - will we still be able to find
> all references to constructors/getters/setters e.t.c. ?
>
> > On May 24, 2018, at 12:54 PM, Brian Towles <bt...@cloudera.com> wrote:
> >
> > Howdy all,
> >
> > I was wondering what the teams thoughts are on using Lombok?
> >
> > https://projectlombok.org/
> >
> > Lombok is a tool that uses annotations at *compile time* to dynamically
> > generate the boilerplate code for things like getters, setters, basic
> > constructors, toString, equals, etc...
> > There are no actual code changes to the source, so its not a traditional
> > generator.  It uses the internal
> > To me it has been a very helpful time saver for coding and maintenance
> and
> > it allows for us to avoid missing things.
> >
> > A good look at how it works in IntelliJ and Eclipse is here:
> >
> https://www.javacodegeeks.com/2016/06/lombok-compile-time-java-annotation-preprocessor-minimize-code-size.html
> >
> > But as a quick example of using this for a very simple class and a single
> > @Data annotation takes:
> >
> > package org.apache.sentry;
> >
> > import lombok.Data;
> >
> > @Data
> > public class SimpleBean {
> >  private final String name;
> >  private int age;
> >  private double score;
> >  private String[] tags;
> > }
> >
> > and turn it effectively into
> >
> > package org.apache.sentry;
> >
> > public class SimpleBean {
> >  private final String name;
> >  private int age;
> >  private double score;
> >  private String[] tags;
> >
> >  @java.beans.ConstructorProperties({"name"})
> >  public SimpleBean(String name) {
> >    this.name = name;
> >  }
> >
> >  public String getName() {
> >    return this.name;
> >  }
> >
> >  public int getAge() {
> >    return this.age;
> >  }
> >
> >  public double getScore() {
> >    return this.score;
> >  }
> >
> >  public String[] getTags() {
> >    return this.tags;
> >  }
> >
> >  public void setAge(int age) {
> >    this.age = age;
> >  }
> >
> >  public void setScore(double score) {
> >    this.score = score;
> >  }
> >
> >  public void setTags(String[] tags) {
> >    this.tags = tags;
> >  }
> >
> >  public boolean equals(Object o) {
> >    if (o == this) {
> >      return true;
> >    }
> >    if (!(o instanceof SimpleBean)) {
> >      return false;
> >    }
> >    final SimpleBean other = (SimpleBean) o;
> >    if (!other.canEqual((Object) this)) {
> >      return false;
> >    }
> >    final Object this$name = this.getName();
> >    final Object other$name = other.getName();
> >    if (this$name == null ? other$name != null :
> > !this$name.equals(other$name)) {
> >      return false;
> >    }
> >    if (this.getAge() != other.getAge()) {
> >      return false;
> >    }
> >    if (Double.compare(this.getScore(), other.getScore()) != 0) {
> >      return false;
> >    }
> >    if (!java.util.Arrays.deepEquals(this.getTags(), other.getTags())) {
> >      return false;
> >    }
> >    return true;
> >  }
> >
> >  public int hashCode() {
> >    final int PRIME = 59;
> >    int result = 1;
> >    final Object $name = this.getName();
> >    result = result * PRIME + ($name == null ? 43 : $name.hashCode());
> >    result = result * PRIME + this.getAge();
> >    final long $score = Double.doubleToLongBits(this.getScore());
> >    result = result * PRIME + (int) ($score >>> 32 ^ $score);
> >    result = result * PRIME +
> java.util.Arrays.deepHashCode(this.getTags());
> >    return result;
> >  }
> >
> >  protected boolean canEqual(Object other) {
> >    return other instanceof SimpleBean;
> >  }
> >
> >  public String toString() {
> >    return "SimpleBean(name=" + this.getName() + ", age=" +
> > this.getAge() + ", score=" + this
> >        .getScore() + ", tags=" +
> > java.util.Arrays.deepToString(this.getTags()) + ")";
> >  }
> > }
> >
> >
> > There are more helper functions in the library for things like Builders,
> > and Synchronized.
> >
> > What do you guys think about using this in Sentry?
> >
> > -=Brian
> >
> > --
> > *Brian Towles* | Software Engineer
> > t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <
> jond@cloudera.com>
> > cloudera.com <http://www.cloudera.com/>
> >
> > [image: Cloudera] <http://www.cloudera.com/>
> >
> > [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
> > Cloudera on Facebook] <https://www.facebook.com/cloudera> [image:
> Cloudera
> > on LinkedIn] <https://www.linkedin.com/company/cloudera>
> > ------------------------------
>
> --
*Brian Towles* | Software Engineer
t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <jo...@cloudera.com>
cloudera.com <http://www.cloudera.com/>

[image: Cloudera] <http://www.cloudera.com/>

[image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
on LinkedIn] <https://www.linkedin.com/company/cloudera>
------------------------------

Re: Thoughts on using lombok?

Posted by Alexander Kolbasov <ak...@cloudera.com>.
Brian,

This seems interesting. How does it interplay with IntelliJ/Eclipse ability to find all usages of the method - will we still be able to find all references to constructors/getters/setters e.t.c. ?

> On May 24, 2018, at 12:54 PM, Brian Towles <bt...@cloudera.com> wrote:
> 
> Howdy all,
> 
> I was wondering what the teams thoughts are on using Lombok?
> 
> https://projectlombok.org/
> 
> Lombok is a tool that uses annotations at *compile time* to dynamically
> generate the boilerplate code for things like getters, setters, basic
> constructors, toString, equals, etc...
> There are no actual code changes to the source, so its not a traditional
> generator.  It uses the internal
> To me it has been a very helpful time saver for coding and maintenance and
> it allows for us to avoid missing things.
> 
> A good look at how it works in IntelliJ and Eclipse is here:
> https://www.javacodegeeks.com/2016/06/lombok-compile-time-java-annotation-preprocessor-minimize-code-size.html
> 
> But as a quick example of using this for a very simple class and a single
> @Data annotation takes:
> 
> package org.apache.sentry;
> 
> import lombok.Data;
> 
> @Data
> public class SimpleBean {
>  private final String name;
>  private int age;
>  private double score;
>  private String[] tags;
> }
> 
> and turn it effectively into
> 
> package org.apache.sentry;
> 
> public class SimpleBean {
>  private final String name;
>  private int age;
>  private double score;
>  private String[] tags;
> 
>  @java.beans.ConstructorProperties({"name"})
>  public SimpleBean(String name) {
>    this.name = name;
>  }
> 
>  public String getName() {
>    return this.name;
>  }
> 
>  public int getAge() {
>    return this.age;
>  }
> 
>  public double getScore() {
>    return this.score;
>  }
> 
>  public String[] getTags() {
>    return this.tags;
>  }
> 
>  public void setAge(int age) {
>    this.age = age;
>  }
> 
>  public void setScore(double score) {
>    this.score = score;
>  }
> 
>  public void setTags(String[] tags) {
>    this.tags = tags;
>  }
> 
>  public boolean equals(Object o) {
>    if (o == this) {
>      return true;
>    }
>    if (!(o instanceof SimpleBean)) {
>      return false;
>    }
>    final SimpleBean other = (SimpleBean) o;
>    if (!other.canEqual((Object) this)) {
>      return false;
>    }
>    final Object this$name = this.getName();
>    final Object other$name = other.getName();
>    if (this$name == null ? other$name != null :
> !this$name.equals(other$name)) {
>      return false;
>    }
>    if (this.getAge() != other.getAge()) {
>      return false;
>    }
>    if (Double.compare(this.getScore(), other.getScore()) != 0) {
>      return false;
>    }
>    if (!java.util.Arrays.deepEquals(this.getTags(), other.getTags())) {
>      return false;
>    }
>    return true;
>  }
> 
>  public int hashCode() {
>    final int PRIME = 59;
>    int result = 1;
>    final Object $name = this.getName();
>    result = result * PRIME + ($name == null ? 43 : $name.hashCode());
>    result = result * PRIME + this.getAge();
>    final long $score = Double.doubleToLongBits(this.getScore());
>    result = result * PRIME + (int) ($score >>> 32 ^ $score);
>    result = result * PRIME + java.util.Arrays.deepHashCode(this.getTags());
>    return result;
>  }
> 
>  protected boolean canEqual(Object other) {
>    return other instanceof SimpleBean;
>  }
> 
>  public String toString() {
>    return "SimpleBean(name=" + this.getName() + ", age=" +
> this.getAge() + ", score=" + this
>        .getScore() + ", tags=" +
> java.util.Arrays.deepToString(this.getTags()) + ")";
>  }
> }
> 
> 
> There are more helper functions in the library for things like Builders,
> and Synchronized.
> 
> What do you guys think about using this in Sentry?
> 
> -=Brian
> 
> -- 
> *Brian Towles* | Software Engineer
> t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <jo...@cloudera.com>
> cloudera.com <http://www.cloudera.com/>
> 
> [image: Cloudera] <http://www.cloudera.com/>
> 
> [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
> Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
> on LinkedIn] <https://www.linkedin.com/company/cloudera>
> ------------------------------


Re: Thoughts on using lombok?

Posted by Brian Towles <bt...@cloudera.com>.
The usage would be for any class that can make use of some of the
attributes.  @Data is a nice one for pojos and entities, but the
constructor ones, Synchronized and others can be used in almost any class.
The @Log/@Slf4j ones are very handy.

It happens at compile time and does not generate source file.

Yes if you define a getter/setter or any function it would automatically
make it uses the coded one and doesn't create the default one from the
annotation.

-=Brian

On Fri, May 25, 2018 at 10:50 AM Stephen Moist <mo...@cloudera.com> wrote:

> Would this mainly be on the DB layer?  With intellij, theres a shortcut to
> auto-gen these fields, does this improve on that?
>
> At compile time, does it overwrite the src or generate a new file?  In the
> case of needing additional logic in a set/get method, can I override that?
>
> > On May 24, 2018, at 11:08 PM, Na Li <li...@cloudera.com> wrote:
> >
> > Brian,
> >
> > That looks quite useful. We can give it a try.
> >
> > Cheers,
> >
> > Lina
> >
> >> On May 24, 2018, at 7:02 PM, Kalyan Kumar Kalvagadda <
> kkalyan@cloudera.com> wrote:
> >>
> >> Brian,
> >>
> >> It will be helpful. I'm in the favor of it.
> >>
> >>
> >> *Thanks,Kalyan Kumar Kalvagadda* | Software Engineer
> >> t. (469) 279- <0000000000>5732
> >> cloudera.com <https://www.cloudera.com>
> >>
> >> [image: Cloudera] <https://www.cloudera.com/>
> >>
> >> [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
> >> Cloudera on Facebook] <https://www.facebook.com/cloudera> [image:
> Cloudera
> >> on LinkedIn] <https://www.linkedin.com/company/cloudera>
> >> ------------------------------
> >>
> >>> On Thu, May 24, 2018 at 2:54 PM, Brian Towles <bt...@cloudera.com>
> wrote:
> >>>
> >>> Howdy all,
> >>>
> >>> I was wondering what the teams thoughts are on using Lombok?
> >>>
> >>> https://projectlombok.org/
> >>>
> >>> Lombok is a tool that uses annotations at *compile time* to dynamically
> >>> generate the boilerplate code for things like getters, setters, basic
> >>> constructors, toString, equals, etc...
> >>> There are no actual code changes to the source, so its not a
> traditional
> >>> generator.  It uses the internal
> >>> To me it has been a very helpful time saver for coding and maintenance
> and
> >>> it allows for us to avoid missing things.
> >>>
> >>> A good look at how it works in IntelliJ and Eclipse is here:
> >>> https://www.javacodegeeks.com/2016/06/lombok-compile-time-
> >>> java-annotation-preprocessor-minimize-code-size.html
> >>>
> >>> But as a quick example of using this for a very simple class and a
> single
> >>> @Data annotation takes:
> >>>
> >>> package org.apache.sentry;
> >>>
> >>> import lombok.Data;
> >>>
> >>> @Data
> >>> public class SimpleBean {
> >>> private final String name;
> >>> private int age;
> >>> private double score;
> >>> private String[] tags;
> >>> }
> >>>
> >>> and turn it effectively into
> >>>
> >>> package org.apache.sentry;
> >>>
> >>> public class SimpleBean {
> >>> private final String name;
> >>> private int age;
> >>> private double score;
> >>> private String[] tags;
> >>>
> >>> @java.beans.ConstructorProperties({"name"})
> >>> public SimpleBean(String name) {
> >>>   this.name = name;
> >>> }
> >>>
> >>> public String getName() {
> >>>   return this.name;
> >>> }
> >>>
> >>> public int getAge() {
> >>>   return this.age;
> >>> }
> >>>
> >>> public double getScore() {
> >>>   return this.score;
> >>> }
> >>>
> >>> public String[] getTags() {
> >>>   return this.tags;
> >>> }
> >>>
> >>> public void setAge(int age) {
> >>>   this.age = age;
> >>> }
> >>>
> >>> public void setScore(double score) {
> >>>   this.score = score;
> >>> }
> >>>
> >>> public void setTags(String[] tags) {
> >>>   this.tags = tags;
> >>> }
> >>>
> >>> public boolean equals(Object o) {
> >>>   if (o == this) {
> >>>     return true;
> >>>   }
> >>>   if (!(o instanceof SimpleBean)) {
> >>>     return false;
> >>>   }
> >>>   final SimpleBean other = (SimpleBean) o;
> >>>   if (!other.canEqual((Object) this)) {
> >>>     return false;
> >>>   }
> >>>   final Object this$name = this.getName();
> >>>   final Object other$name = other.getName();
> >>>   if (this$name == null ? other$name != null :
> >>> !this$name.equals(other$name)) {
> >>>     return false;
> >>>   }
> >>>   if (this.getAge() != other.getAge()) {
> >>>     return false;
> >>>   }
> >>>   if (Double.compare(this.getScore(), other.getScore()) != 0) {
> >>>     return false;
> >>>   }
> >>>   if (!java.util.Arrays.deepEquals(this.getTags(), other.getTags())) {
> >>>     return false;
> >>>   }
> >>>   return true;
> >>> }
> >>>
> >>> public int hashCode() {
> >>>   final int PRIME = 59;
> >>>   int result = 1;
> >>>   final Object $name = this.getName();
> >>>   result = result * PRIME + ($name == null ? 43 : $name.hashCode());
> >>>   result = result * PRIME + this.getAge();
> >>>   final long $score = Double.doubleToLongBits(this.getScore());
> >>>   result = result * PRIME + (int) ($score >>> 32 ^ $score);
> >>>   result = result * PRIME + java.util.Arrays.deepHashCode(
> >>> this.getTags());
> >>>   return result;
> >>> }
> >>>
> >>> protected boolean canEqual(Object other) {
> >>>   return other instanceof SimpleBean;
> >>> }
> >>>
> >>> public String toString() {
> >>>   return "SimpleBean(name=" + this.getName() + ", age=" +
> >>> this.getAge() + ", score=" + this
> >>>       .getScore() + ", tags=" +
> >>> java.util.Arrays.deepToString(this.getTags()) + ")";
> >>> }
> >>> }
> >>>
> >>>
> >>> There are more helper functions in the library for things like
> Builders,
> >>> and Synchronized.
> >>>
> >>> What do you guys think about using this in Sentry?
> >>>
> >>> -=Brian
> >>>
> >>> --
> >>> *Brian Towles* | Software Engineer
> >>> t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <
> jond@cloudera.com>
> >>> cloudera.com <http://www.cloudera.com/>
> >>>
> >>> [image: Cloudera] <http://www.cloudera.com/>
> >>>
> >>> [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
> >>> Cloudera on Facebook] <https://www.facebook.com/cloudera> [image:
> Cloudera
> >>> on LinkedIn] <https://www.linkedin.com/company/cloudera>
> >>> ------------------------------
> >>>
>
> --
*Brian Towles* | Software Engineer
t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <jo...@cloudera.com>
cloudera.com <http://www.cloudera.com/>

[image: Cloudera] <http://www.cloudera.com/>

[image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
on LinkedIn] <https://www.linkedin.com/company/cloudera>
------------------------------

Re: Thoughts on using lombok?

Posted by Stephen Moist <mo...@cloudera.com>.
Would this mainly be on the DB layer?  With intellij, theres a shortcut to auto-gen these fields, does this improve on that?

At compile time, does it overwrite the src or generate a new file?  In the case of needing additional logic in a set/get method, can I override that?

> On May 24, 2018, at 11:08 PM, Na Li <li...@cloudera.com> wrote:
> 
> Brian,
> 
> That looks quite useful. We can give it a try.
> 
> Cheers,
> 
> Lina
> 
>> On May 24, 2018, at 7:02 PM, Kalyan Kumar Kalvagadda <kk...@cloudera.com> wrote:
>> 
>> Brian,
>> 
>> It will be helpful. I'm in the favor of it.
>> 
>> 
>> *Thanks,Kalyan Kumar Kalvagadda* | Software Engineer
>> t. (469) 279- <0000000000>5732
>> cloudera.com <https://www.cloudera.com>
>> 
>> [image: Cloudera] <https://www.cloudera.com/>
>> 
>> [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
>> Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
>> on LinkedIn] <https://www.linkedin.com/company/cloudera>
>> ------------------------------
>> 
>>> On Thu, May 24, 2018 at 2:54 PM, Brian Towles <bt...@cloudera.com> wrote:
>>> 
>>> Howdy all,
>>> 
>>> I was wondering what the teams thoughts are on using Lombok?
>>> 
>>> https://projectlombok.org/
>>> 
>>> Lombok is a tool that uses annotations at *compile time* to dynamically
>>> generate the boilerplate code for things like getters, setters, basic
>>> constructors, toString, equals, etc...
>>> There are no actual code changes to the source, so its not a traditional
>>> generator.  It uses the internal
>>> To me it has been a very helpful time saver for coding and maintenance and
>>> it allows for us to avoid missing things.
>>> 
>>> A good look at how it works in IntelliJ and Eclipse is here:
>>> https://www.javacodegeeks.com/2016/06/lombok-compile-time-
>>> java-annotation-preprocessor-minimize-code-size.html
>>> 
>>> But as a quick example of using this for a very simple class and a single
>>> @Data annotation takes:
>>> 
>>> package org.apache.sentry;
>>> 
>>> import lombok.Data;
>>> 
>>> @Data
>>> public class SimpleBean {
>>> private final String name;
>>> private int age;
>>> private double score;
>>> private String[] tags;
>>> }
>>> 
>>> and turn it effectively into
>>> 
>>> package org.apache.sentry;
>>> 
>>> public class SimpleBean {
>>> private final String name;
>>> private int age;
>>> private double score;
>>> private String[] tags;
>>> 
>>> @java.beans.ConstructorProperties({"name"})
>>> public SimpleBean(String name) {
>>>   this.name = name;
>>> }
>>> 
>>> public String getName() {
>>>   return this.name;
>>> }
>>> 
>>> public int getAge() {
>>>   return this.age;
>>> }
>>> 
>>> public double getScore() {
>>>   return this.score;
>>> }
>>> 
>>> public String[] getTags() {
>>>   return this.tags;
>>> }
>>> 
>>> public void setAge(int age) {
>>>   this.age = age;
>>> }
>>> 
>>> public void setScore(double score) {
>>>   this.score = score;
>>> }
>>> 
>>> public void setTags(String[] tags) {
>>>   this.tags = tags;
>>> }
>>> 
>>> public boolean equals(Object o) {
>>>   if (o == this) {
>>>     return true;
>>>   }
>>>   if (!(o instanceof SimpleBean)) {
>>>     return false;
>>>   }
>>>   final SimpleBean other = (SimpleBean) o;
>>>   if (!other.canEqual((Object) this)) {
>>>     return false;
>>>   }
>>>   final Object this$name = this.getName();
>>>   final Object other$name = other.getName();
>>>   if (this$name == null ? other$name != null :
>>> !this$name.equals(other$name)) {
>>>     return false;
>>>   }
>>>   if (this.getAge() != other.getAge()) {
>>>     return false;
>>>   }
>>>   if (Double.compare(this.getScore(), other.getScore()) != 0) {
>>>     return false;
>>>   }
>>>   if (!java.util.Arrays.deepEquals(this.getTags(), other.getTags())) {
>>>     return false;
>>>   }
>>>   return true;
>>> }
>>> 
>>> public int hashCode() {
>>>   final int PRIME = 59;
>>>   int result = 1;
>>>   final Object $name = this.getName();
>>>   result = result * PRIME + ($name == null ? 43 : $name.hashCode());
>>>   result = result * PRIME + this.getAge();
>>>   final long $score = Double.doubleToLongBits(this.getScore());
>>>   result = result * PRIME + (int) ($score >>> 32 ^ $score);
>>>   result = result * PRIME + java.util.Arrays.deepHashCode(
>>> this.getTags());
>>>   return result;
>>> }
>>> 
>>> protected boolean canEqual(Object other) {
>>>   return other instanceof SimpleBean;
>>> }
>>> 
>>> public String toString() {
>>>   return "SimpleBean(name=" + this.getName() + ", age=" +
>>> this.getAge() + ", score=" + this
>>>       .getScore() + ", tags=" +
>>> java.util.Arrays.deepToString(this.getTags()) + ")";
>>> }
>>> }
>>> 
>>> 
>>> There are more helper functions in the library for things like Builders,
>>> and Synchronized.
>>> 
>>> What do you guys think about using this in Sentry?
>>> 
>>> -=Brian
>>> 
>>> --
>>> *Brian Towles* | Software Engineer
>>> t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <jo...@cloudera.com>
>>> cloudera.com <http://www.cloudera.com/>
>>> 
>>> [image: Cloudera] <http://www.cloudera.com/>
>>> 
>>> [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
>>> Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
>>> on LinkedIn] <https://www.linkedin.com/company/cloudera>
>>> ------------------------------
>>> 


Re: Thoughts on using lombok?

Posted by Na Li <li...@cloudera.com>.
Brian,

That looks quite useful. We can give it a try.

Cheers,

Lina

> On May 24, 2018, at 7:02 PM, Kalyan Kumar Kalvagadda <kk...@cloudera.com> wrote:
> 
> Brian,
> 
> It will be helpful. I'm in the favor of it.
> 
> 
> *Thanks,Kalyan Kumar Kalvagadda* | Software Engineer
> t. (469) 279- <0000000000>5732
> cloudera.com <https://www.cloudera.com>
> 
> [image: Cloudera] <https://www.cloudera.com/>
> 
> [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
> Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
> on LinkedIn] <https://www.linkedin.com/company/cloudera>
> ------------------------------
> 
>> On Thu, May 24, 2018 at 2:54 PM, Brian Towles <bt...@cloudera.com> wrote:
>> 
>> Howdy all,
>> 
>> I was wondering what the teams thoughts are on using Lombok?
>> 
>> https://projectlombok.org/
>> 
>> Lombok is a tool that uses annotations at *compile time* to dynamically
>> generate the boilerplate code for things like getters, setters, basic
>> constructors, toString, equals, etc...
>> There are no actual code changes to the source, so its not a traditional
>> generator.  It uses the internal
>> To me it has been a very helpful time saver for coding and maintenance and
>> it allows for us to avoid missing things.
>> 
>> A good look at how it works in IntelliJ and Eclipse is here:
>> https://www.javacodegeeks.com/2016/06/lombok-compile-time-
>> java-annotation-preprocessor-minimize-code-size.html
>> 
>> But as a quick example of using this for a very simple class and a single
>> @Data annotation takes:
>> 
>> package org.apache.sentry;
>> 
>> import lombok.Data;
>> 
>> @Data
>> public class SimpleBean {
>>  private final String name;
>>  private int age;
>>  private double score;
>>  private String[] tags;
>> }
>> 
>> and turn it effectively into
>> 
>> package org.apache.sentry;
>> 
>> public class SimpleBean {
>>  private final String name;
>>  private int age;
>>  private double score;
>>  private String[] tags;
>> 
>>  @java.beans.ConstructorProperties({"name"})
>>  public SimpleBean(String name) {
>>    this.name = name;
>>  }
>> 
>>  public String getName() {
>>    return this.name;
>>  }
>> 
>>  public int getAge() {
>>    return this.age;
>>  }
>> 
>>  public double getScore() {
>>    return this.score;
>>  }
>> 
>>  public String[] getTags() {
>>    return this.tags;
>>  }
>> 
>>  public void setAge(int age) {
>>    this.age = age;
>>  }
>> 
>>  public void setScore(double score) {
>>    this.score = score;
>>  }
>> 
>>  public void setTags(String[] tags) {
>>    this.tags = tags;
>>  }
>> 
>>  public boolean equals(Object o) {
>>    if (o == this) {
>>      return true;
>>    }
>>    if (!(o instanceof SimpleBean)) {
>>      return false;
>>    }
>>    final SimpleBean other = (SimpleBean) o;
>>    if (!other.canEqual((Object) this)) {
>>      return false;
>>    }
>>    final Object this$name = this.getName();
>>    final Object other$name = other.getName();
>>    if (this$name == null ? other$name != null :
>> !this$name.equals(other$name)) {
>>      return false;
>>    }
>>    if (this.getAge() != other.getAge()) {
>>      return false;
>>    }
>>    if (Double.compare(this.getScore(), other.getScore()) != 0) {
>>      return false;
>>    }
>>    if (!java.util.Arrays.deepEquals(this.getTags(), other.getTags())) {
>>      return false;
>>    }
>>    return true;
>>  }
>> 
>>  public int hashCode() {
>>    final int PRIME = 59;
>>    int result = 1;
>>    final Object $name = this.getName();
>>    result = result * PRIME + ($name == null ? 43 : $name.hashCode());
>>    result = result * PRIME + this.getAge();
>>    final long $score = Double.doubleToLongBits(this.getScore());
>>    result = result * PRIME + (int) ($score >>> 32 ^ $score);
>>    result = result * PRIME + java.util.Arrays.deepHashCode(
>> this.getTags());
>>    return result;
>>  }
>> 
>>  protected boolean canEqual(Object other) {
>>    return other instanceof SimpleBean;
>>  }
>> 
>>  public String toString() {
>>    return "SimpleBean(name=" + this.getName() + ", age=" +
>> this.getAge() + ", score=" + this
>>        .getScore() + ", tags=" +
>> java.util.Arrays.deepToString(this.getTags()) + ")";
>>  }
>> }
>> 
>> 
>> There are more helper functions in the library for things like Builders,
>> and Synchronized.
>> 
>> What do you guys think about using this in Sentry?
>> 
>> -=Brian
>> 
>> --
>> *Brian Towles* | Software Engineer
>> t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <jo...@cloudera.com>
>> cloudera.com <http://www.cloudera.com/>
>> 
>> [image: Cloudera] <http://www.cloudera.com/>
>> 
>> [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
>> Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
>> on LinkedIn] <https://www.linkedin.com/company/cloudera>
>> ------------------------------
>> 

Re: Thoughts on using lombok?

Posted by Kalyan Kumar Kalvagadda <kk...@cloudera.com>.
Brian,

It will be helpful. I'm in the favor of it.


*Thanks,Kalyan Kumar Kalvagadda* | Software Engineer
t. (469) 279- <0000000000>5732
cloudera.com <https://www.cloudera.com>

[image: Cloudera] <https://www.cloudera.com/>

[image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
on LinkedIn] <https://www.linkedin.com/company/cloudera>
------------------------------

On Thu, May 24, 2018 at 2:54 PM, Brian Towles <bt...@cloudera.com> wrote:

> Howdy all,
>
> I was wondering what the teams thoughts are on using Lombok?
>
> https://projectlombok.org/
>
> Lombok is a tool that uses annotations at *compile time* to dynamically
> generate the boilerplate code for things like getters, setters, basic
> constructors, toString, equals, etc...
> There are no actual code changes to the source, so its not a traditional
> generator.  It uses the internal
> To me it has been a very helpful time saver for coding and maintenance and
> it allows for us to avoid missing things.
>
> A good look at how it works in IntelliJ and Eclipse is here:
> https://www.javacodegeeks.com/2016/06/lombok-compile-time-
> java-annotation-preprocessor-minimize-code-size.html
>
> But as a quick example of using this for a very simple class and a single
> @Data annotation takes:
>
> package org.apache.sentry;
>
> import lombok.Data;
>
> @Data
> public class SimpleBean {
>   private final String name;
>   private int age;
>   private double score;
>   private String[] tags;
> }
>
> and turn it effectively into
>
> package org.apache.sentry;
>
> public class SimpleBean {
>   private final String name;
>   private int age;
>   private double score;
>   private String[] tags;
>
>   @java.beans.ConstructorProperties({"name"})
>   public SimpleBean(String name) {
>     this.name = name;
>   }
>
>   public String getName() {
>     return this.name;
>   }
>
>   public int getAge() {
>     return this.age;
>   }
>
>   public double getScore() {
>     return this.score;
>   }
>
>   public String[] getTags() {
>     return this.tags;
>   }
>
>   public void setAge(int age) {
>     this.age = age;
>   }
>
>   public void setScore(double score) {
>     this.score = score;
>   }
>
>   public void setTags(String[] tags) {
>     this.tags = tags;
>   }
>
>   public boolean equals(Object o) {
>     if (o == this) {
>       return true;
>     }
>     if (!(o instanceof SimpleBean)) {
>       return false;
>     }
>     final SimpleBean other = (SimpleBean) o;
>     if (!other.canEqual((Object) this)) {
>       return false;
>     }
>     final Object this$name = this.getName();
>     final Object other$name = other.getName();
>     if (this$name == null ? other$name != null :
> !this$name.equals(other$name)) {
>       return false;
>     }
>     if (this.getAge() != other.getAge()) {
>       return false;
>     }
>     if (Double.compare(this.getScore(), other.getScore()) != 0) {
>       return false;
>     }
>     if (!java.util.Arrays.deepEquals(this.getTags(), other.getTags())) {
>       return false;
>     }
>     return true;
>   }
>
>   public int hashCode() {
>     final int PRIME = 59;
>     int result = 1;
>     final Object $name = this.getName();
>     result = result * PRIME + ($name == null ? 43 : $name.hashCode());
>     result = result * PRIME + this.getAge();
>     final long $score = Double.doubleToLongBits(this.getScore());
>     result = result * PRIME + (int) ($score >>> 32 ^ $score);
>     result = result * PRIME + java.util.Arrays.deepHashCode(
> this.getTags());
>     return result;
>   }
>
>   protected boolean canEqual(Object other) {
>     return other instanceof SimpleBean;
>   }
>
>   public String toString() {
>     return "SimpleBean(name=" + this.getName() + ", age=" +
> this.getAge() + ", score=" + this
>         .getScore() + ", tags=" +
> java.util.Arrays.deepToString(this.getTags()) + ")";
>   }
> }
>
>
> There are more helper functions in the library for things like Builders,
> and Synchronized.
>
> What do you guys think about using this in Sentry?
>
> -=Brian
>
> --
> *Brian Towles* | Software Engineer
> t. (512) 415- <0000000000>8105 e. btowles@cloudera.com <jo...@cloudera.com>
> cloudera.com <http://www.cloudera.com/>
>
> [image: Cloudera] <http://www.cloudera.com/>
>
> [image: Cloudera on Twitter] <https://twitter.com/cloudera> [image:
> Cloudera on Facebook] <https://www.facebook.com/cloudera> [image: Cloudera
> on LinkedIn] <https://www.linkedin.com/company/cloudera>
> ------------------------------
>