Skip to content

Commit

Permalink
generated interfaces doesn't need to be public.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehedi authored and iamMehedi committed Mar 31, 2016
1 parent 0e1d9e4 commit 6b7c6d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ StepBuilder Generator
plugin that adds a 'Step Builder' action to the Generate menu (Alt+Insert)
which generates a Builder class which follows the Step Builder pattern. You can
read about the Step Builder pattern and why it might be a little more effective than
the usual Builder pattern [here](http://www.jayway.com/2012/02/07/builder-pattern-with-a-twist/).
the usual Builder pattern [here](http://devliving.online/stepbuilder-builder-that-guides-you-through-the-steps/).

![screenshot](screenshot_1.png)

Expand Down
7 changes: 6 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<id>online.devliving.stepbuilder.generator</id>
<name>StepBuilder Generator</name>
<version>1.0</version>
<version>1.0.1</version>
<vendor email="[email protected]" url="http://www.devliving.online">Mehedi Hasan Khan</vendor>

<description><![CDATA[
Expand Down Expand Up @@ -127,6 +127,11 @@
<td> 1.0.0</td>
<td>First release</td>
</tr>
<tr>
<td> 1.0.1</td>
<td>Generated interfaces aren't public</td>
</tr>
</table>
]]>
</change-notes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ public void run() {
}

private PsiClass createBuildStepInterface(){
return psiElementFactory.createInterface(INTERFACE_NAME_PREFIX + BUILD_STEP_INTERFACE_NAME);
PsiClass buildStep = psiElementFactory.createInterface(INTERFACE_NAME_PREFIX + BUILD_STEP_INTERFACE_NAME);
if(buildStep.getModifierList() != null){
buildStep.getModifierList().setModifierProperty(PsiModifier.PUBLIC, false);
}

return buildStep;
}

/**
Expand All @@ -229,6 +234,9 @@ private PsiClass generateMandatoryInterface(PsiFieldMember forMember, PsiType re
BUILDER_SETTER_ALTERNATIVE_PARAMETER_NAME:BUILDER_SETTER_DEFAULT_PARAMETER_NAME;

PsiClass mInterface = psiElementFactory.createInterface(INTERFACE_NAME_PREFIX + capitalizedFieldName);
if(mInterface.getModifierList() != null){
mInterface.getModifierList().setModifierProperty(PsiModifier.PUBLIC, false);
}

PsiMethod fieldMethod = psiElementFactory.createMethodFromText(String.format("%s %s(%s %s);", returnType.getPresentableText(),
methodName, forMember.getElement().getType().getPresentableText(), paramName), mInterface);
Expand Down

0 comments on commit 6b7c6d4

Please sign in to comment.