Skip to content

Commit

Permalink
adding a specific public builder for each option type, instead of mak…
Browse files Browse the repository at this point in the history
…ing OptionType public.
  • Loading branch information
perezd committed Jul 22, 2018
1 parent 8259318 commit 82c74aa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
42 changes: 41 additions & 1 deletion java/protopoet/OptionSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,48 @@
*/
public final class OptionSpec implements Buildable<OptionSpec>, Emittable {

/** Creates a builder for a File {@link OptionSpec}. */
public static Builder fileOption(String optionName) {
return builder(OptionType.FILE, optionName);
}

/** Creates a builder for a Message {@link OptionSpec}. */
public static Builder messageOption(String optionName) {
return builder(OptionType.MESSAGE, optionName);
}

/** Creates a builder for a Field {@link OptionSpec}. */
public static Builder fieldOption(String optionName) {
return builder(OptionType.FIELD, optionName);
}

/** Creates a builder for a Enum {@link OptionSpec}. */
public static Builder enumOption(String optionName) {
return builder(OptionType.ENUM, optionName);
}

/** Creates a builder for a Enum Value {@link OptionSpec}. */
public static Builder enumValueOption(String optionName) {
return builder(OptionType.ENUM_VALUE, optionName);
}

/** Creates a builder for a Service {@link OptionSpec}. */
public static Builder serviceOption(String optionName) {
return builder(OptionType.SERVICE, optionName);
}

/** Creates a builder for a Oneof {@link OptionSpec}. */
public static Builder oneofOption(String optionName) {
return builder(OptionType.ONEOF, optionName);
}

/** Creates a builder for a Method {@link OptionSpec}. */
public static Builder methodOption(String optionName) {
return builder(OptionType.METHOD, optionName);
}

/** Creates a builder for an {@link OptionSpec}. */
public static Builder builder(OptionType optionType, String optionName) {
static Builder builder(OptionType optionType, String optionName) {
checkNotNull(optionType, "option type may not be null");
checkNotNull(optionName, "option name may not be null");
return new Builder(optionType, optionName);
Expand Down
2 changes: 1 addition & 1 deletion java/protopoet/OptionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Valid types of options available in the Protocol Buffers language.
* Learn more: https://developers.google.com/protocol-buffers/docs/proto#customoptions
*/
public enum OptionType {
enum OptionType {
/** See {@link ProtoFile} for more info. */
FILE("FileOptions"),

Expand Down

0 comments on commit 82c74aa

Please sign in to comment.