Skip to content

Commit

Permalink
Remove unnecssary parentheses detected by checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
yichen88 committed Sep 27, 2017
1 parent 65daaba commit 5b9aa7e
Show file tree
Hide file tree
Showing 38 changed files with 86 additions and 85 deletions.
12 changes: 6 additions & 6 deletions EU2Mod_MB/src/main/java/itesla/converter/ParParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,28 @@ private void ParConfiguration() {
}

public String getModelName() {
return (modelName);
return modelName;
}

public Integer getnParameters() {
return (nParameters);
return nParameters;
}

public Integer getnSets() {
return (nSets);
return nSets;
}

public List<String> getParNames() {
return (parNames);
return parNames;
}

public List<Integer> getSetIds() {
return (setIds);
return setIds;
}


public HashMap<String, String> getParTypes() {
return (parTypes);
return parTypes;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ private void writeBranches(AmplExportContext context) throws IOException {
float ratio = ratedU2 / vb2 / (ratedU1 / vb1);
RatioTapChanger rtc = twt.getRatioTapChanger();
PhaseTapChanger ptc = twt.getPhaseTapChanger();
int rtcNum = (rtc != null ? mapper.getInt(AmplSubset.RATIO_TAP_CHANGER, twt.getId()) : -1);
int ptcNum = (ptc != null ? mapper.getInt(AmplSubset.PHASE_TAP_CHANGER, twt.getId()) : -1);
int rtcNum = rtc != null ? mapper.getInt(AmplSubset.RATIO_TAP_CHANGER, twt.getId()) : -1;
int ptcNum = ptc != null ? mapper.getInt(AmplSubset.PHASE_TAP_CHANGER, twt.getId()) : -1;
formatter.writeCell(num)
.writeCell(bus1Num)
.writeCell(bus2Num)
Expand Down Expand Up @@ -697,8 +697,8 @@ private void writeBranches(AmplExportContext context) throws IOException {
float ratio3 = ratedU1 / ratedU3;
RatioTapChanger rtc2 = twt.getLeg2().getRatioTapChanger();
RatioTapChanger rtc3 = twt.getLeg2().getRatioTapChanger();
int rtc2Num = (rtc2 != null ? mapper.getInt(AmplSubset.RATIO_TAP_CHANGER, id2) : -1);
int rtc3Num = (rtc3 != null ? mapper.getInt(AmplSubset.RATIO_TAP_CHANGER, id3) : -1);
int rtc2Num = rtc2 != null ? mapper.getInt(AmplSubset.RATIO_TAP_CHANGER, id2) : -1;
int rtc3Num = rtc3 != null ? mapper.getInt(AmplSubset.RATIO_TAP_CHANGER, id3) : -1;

int middleVlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, getThreeWindingsTransformerMiddleVoltageLevelId(twt));
String middleBusId = getThreeWindingsTransformerMiddleBusId(twt);
Expand Down
1 change: 1 addition & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<module name="UnnecessaryParentheses"/>
<module name="UnusedImports"/>
</module>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ private double getFaultDuration(ContingencyElement element) {
case MO_LINE_OPEN_REC:
return ((MoLineOpenRecContingency) element).getT2() - ((MoLineOpenRecContingency) element).getT1();
case MO_LINE_2_OPEN:
return (parameters.getPostFaultSimulationStopInstant() - ((MoLine2OpenContingency) element).getT1());
return parameters.getPostFaultSimulationStopInstant() - ((MoLine2OpenContingency) element).getT1();
case MO_BANK_MODIF:
return (parameters.getPostFaultSimulationStopInstant() - ((MoBankModifContingency) element).getT1());
return parameters.getPostFaultSimulationStopInstant() - ((MoBankModifContingency) element).getT1();
case MO_LOAD_MODIF:
return (parameters.getPostFaultSimulationStopInstant() - ((MoLoadModifContingency) element).getT1());
return parameters.getPostFaultSimulationStopInstant() - ((MoLoadModifContingency) element).getT1();
case MO_BREAKER:
return (parameters.getPostFaultSimulationStopInstant() - ((MoBreakerContingency) element).getT1());
return parameters.getPostFaultSimulationStopInstant() - ((MoBreakerContingency) element).getT1();
case MO_SETPOINT_MODIF:
return (parameters.getPostFaultSimulationStopInstant() - ((MoSetPointModifContingency) element).getT1());
return parameters.getPostFaultSimulationStopInstant() - ((MoSetPointModifContingency) element).getT1();
default:
throw new AssertionError();
}
Expand Down Expand Up @@ -180,7 +180,7 @@ private void readSecurityIndexes(List<Contingency> contingencies, Path workingDi
// also scan errors in output
//EurostagUtil.searchErrorMessage(workingDir.resolve(FAULT_OUT_GZ_FILE_NAME.replace(Command.EXECUTION_NUMBER_PATTERN, Integer.toString(i))), result.getMetrics(), i);
}
LOGGER.trace("{} security indexes files read in {} ms", files, (System.currentTimeMillis() - start));
LOGGER.trace("{} security indexes files read in {} ms", files, System.currentTimeMillis() - start);
}

//OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private EsgNode createNode(String busId, VoltageLevel vl, float v, float angle,
private void createNodes(EsgNetwork esgNetwork) {
fakeNodes.referencedEsgIdsAsStream().forEach(esgId -> {
VoltageLevel vlevel = fakeNodes.getVoltageLevelByEsgId(esgId);
float nominalV = ((vlevel != null) ? vlevel.getNominalV() : 380f);
float nominalV = (vlevel != null) ? vlevel.getNominalV() : 380f;
esgNetwork.addNode(createNode(esgId, EchUtil.FAKE_AREA, nominalV, nominalV, 0f, false));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public long countUses(String id) {

//the esg nodes ids that are referenced at least once
public Stream<String> referencedEsgIdsAsStream() {
return fakeNodesMap.values().stream().filter(esgId -> (countUses(esgId) > 0));
return fakeNodesMap.values().stream().filter(esgId -> countUses(esgId) > 0);
}

public Stream<String> esgIdsAsStream() {
Expand All @@ -99,7 +99,7 @@ public String getEsgIdAndIncCounter(Terminal t) {

public VoltageLevel getVoltageLevelByEsgId(String esgId) {
String voltageLevelId = fakeNodesMap.inverse().get(esgId);
return (voltageLevelId != null ? network.getVoltageLevel(voltageLevelId) : null);
return voltageLevelId != null ? network.getVoltageLevel(voltageLevelId) : null;
}

private String getEsgIdAndIncCounter(VoltageLevel vl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private void readSecurityIndexes(List<Contingency> contingencies, Path workingDi
EurostagUtil.searchErrorMessage(workingDir.resolve(FAULT_OUT_GZ_FILE_NAME.replace(Command.EXECUTION_NUMBER_PATTERN, Integer.toString(i))), result.getMetrics(), i);
}

LOGGER.trace("{} security indexes files read in {} ms", files, (System.currentTimeMillis() - start));
LOGGER.trace("{} security indexes files read in {} ms", files, System.currentTimeMillis() - start);
}

private static EurostagDictionary getDictionary(Map<String, Object> context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ private EurostagStepUpTransformerInserter() {
* qhvgen qhvload
*/
private static StateVariable toLvGenPf(TransformerModel transformerModel, StateVariable hvGenSv, PowerFlow hvLoadPf, PowerFlow lvLoadPf) {
double p1 = (hvGenSv.p + (hvLoadPf != null ? hvLoadPf.p : 0f));
double q1 = (hvGenSv.q + (hvLoadPf != null ? hvLoadPf.q : 0f));
double p1 = hvGenSv.p + (hvLoadPf != null ? hvLoadPf.p : 0f);
double q1 = hvGenSv.q + (hvLoadPf != null ? hvLoadPf.q : 0f);
StateVariable sv1 = new StateVariable(p1, q1, hvGenSv.u, hvGenSv.theta);
StateVariable sv2 = transformerModel.toSv2(sv1);
double pLvGen = -(sv2.p + (lvLoadPf != null ? lvLoadPf.p : 0f));
Expand Down Expand Up @@ -699,7 +699,7 @@ public static void insert(Network n, LoadFlowFactory loadFlowFactory, Computatio
for (Generator g : Identifiables.sort(n.getGenerators())) {
count.get(insert(g, ddb, genDict, auxDict, config, stateBefore)).add(g.getId());
}
LOGGER.info("{} step-up transformers added in {} ms", count.get(InsertionStatus.OK).size(), (System.currentTimeMillis() - start));
LOGGER.info("{} step-up transformers added in {} ms", count.get(InsertionStatus.OK).size(), System.currentTimeMillis() - start);

int generatorsNotMoved = n.getGeneratorCount() - count.get(InsertionStatus.OK).size();
if (generatorsNotMoved > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ private List<Object> getFilteredContent(Operand op) {
}

private boolean isConstant(Operand op) {
return (getFilteredContent(op).size() == 1 && getFilteredContent(op).get(0) instanceof String);
return getFilteredContent(op).size() == 1 && getFilteredContent(op).get(0) instanceof String;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public void setDefaultParameters(List<DefaultParameters> defaultParameters) {

public DefaultParameters defaultParametersBySetNum(int defSetNum) {
int defParsSetsSize = defaultParameters.size();
if ((defParsSetsSize > 0)) {
if (defParsSetsSize > 0) {
DefaultParameters foundDP = null;
for (DefaultParameters defaultParams : defaultParameters) {
if (defaultParams.getSetNum() == defSetNum) {
foundDP = defaultParams;
break;
}
}
return ((foundDP != null) ? foundDP : null);
return (foundDP != null) ? foundDP : null;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public Equipment findEquipment(String cimId) {
Equipment.class);
query.setParameter("arg1", cimId);
List<Equipment> res = query.getResultList();
return (res.size() > 0 ? res.get(0) : null);
return res.size() > 0 ? res.get(0) : null;
}

public List<Internal> findInternalsAll() {
Expand Down Expand Up @@ -271,15 +271,15 @@ public List<Internal> findInternalsAllMaxResults(int firstResult, int maxResult)

public Internal findInternal(String nativeId) {
Principal cPrincipal = getCallerPrincipal();
if ((nativeId == null)) {
if (nativeId == null) {
throw new RuntimeException("nativeId must be not null");
}
TypedQuery<Internal> query = em.createQuery(
"SELECT m FROM Internal m WHERE m.nativeId = :arg1",
Internal.class);
query.setParameter("arg1", nativeId);
List<Internal> res = query.getResultList();
return (res.size() > 0 ? res.get(0) : null);
return res.size() > 0 ? res.get(0) : null;
}

public List<ModelTemplateContainer> findModelTemplateContainerAll() {
Expand Down Expand Up @@ -314,7 +314,7 @@ public ModelTemplateContainer findModelTemplateContainer(String ddbId) {
ModelTemplateContainer.class);
query.setParameter("arg1", ddbId);
List<ModelTemplateContainer> res = query.getResultList();
return (res.size() > 0 ? res.get(0) : null);
return res.size() > 0 ? res.get(0) : null;
}

public ParametersContainer findParametersContainer(String ddbId) {
Expand All @@ -324,7 +324,7 @@ public ParametersContainer findParametersContainer(String ddbId) {
ParametersContainer.class);
query.setParameter("arg1", ddbId);
List<ParametersContainer> res = query.getResultList();
return (res.size() > 0 ? res.get(0) : null);
return res.size() > 0 ? res.get(0) : null;
}

public List<ParametersContainer> findParametersContainerAll() {
Expand Down Expand Up @@ -391,7 +391,7 @@ public SimulatorInst findSimulator(Simulator sim, String version) {
query.setParameter("arg1", version);
query.setParameter("arg2", sim);
List<SimulatorInst> res = query.getResultList();
return ((res.size() == 0) ? null : res.get(0));
return (res.size() == 0) ? null : res.get(0);
}

public List<SimulatorInst> findSimulatorsAll() {
Expand Down Expand Up @@ -468,7 +468,7 @@ public ModelTemplate findModelTemplate(Equipment equipment,
throw new RuntimeException("Equipment and SimulatorInst must be not null");
}
Principal cPrincipal = getCallerPrincipal();
return ((equipment == null) ? null : this.findModelTemplate(equipment.getModelContainer(), simulator));
return (equipment == null) ? null : this.findModelTemplate(equipment.getModelContainer(), simulator);
}


Expand Down Expand Up @@ -538,7 +538,7 @@ public Float getFloatParameter(Equipment equipment,
ParameterFloat par = getParameterOrDefaultByNameAndType(equipment, simulator,
name,
ParameterFloat.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getStringParameterEquipment")
Expand All @@ -547,7 +547,7 @@ public String getStringParameter(Equipment equipment,
ParameterString par = getParameterOrDefaultByNameAndType(equipment, simulator,
name,
ParameterString.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getIntegerParameterEquipment")
Expand All @@ -556,7 +556,7 @@ public Integer getIntegerParameter(Equipment equipment,
ParameterInteger par = getParameterOrDefaultByNameAndType(equipment, simulator,
name,
ParameterInteger.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getBooleanParameterEquipment")
Expand All @@ -565,7 +565,7 @@ public Boolean getBooleanParameter(Equipment equipment,
ParameterBoolean par = getParameterOrDefaultByNameAndType(equipment, simulator,
name,
ParameterBoolean.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getTableParameterEquipment")
Expand All @@ -575,7 +575,7 @@ public ParameterTable getTableParameter(Equipment equipment,
ParameterTable par = getParameterOrDefaultByNameAndType(equipment, simulator,
name,
ParameterTable.class);
return ((par != null) ? (par) : null);
return (par != null) ? par : null;
}


Expand Down Expand Up @@ -647,7 +647,7 @@ public Float getFloatParameter(Internal internal, SimulatorInst simulator,
simulator,
name,
ParameterFloat.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getStringParameterInternal")
Expand All @@ -658,7 +658,7 @@ public String getStringParameter(Internal internal, SimulatorInst simulator,
simulator,
name,
ParameterString.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getIntegerParameterInternal")
Expand All @@ -669,7 +669,7 @@ public Integer getIntegerParameter(Internal internal, SimulatorInst simulator,
simulator,
name,
ParameterInteger.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getBooleanParameterInternal")
Expand All @@ -680,7 +680,7 @@ public Boolean getBooleanParameter(Internal internal, SimulatorInst simulator,
simulator,
name,
ParameterBoolean.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getTableParameterInternal")
Expand All @@ -690,7 +690,7 @@ public ParameterTable getTableParameter(Internal internal, SimulatorInst simulat
simulator,
name,
ParameterTable.class);
return ((par != null) ? (par) : null);
return (par != null) ? par : null;
}


Expand Down Expand Up @@ -782,7 +782,7 @@ public Float getFloatParameter(ParametersContainer parametersContainer,
ParameterFloat par = getParameterByNameAndType(parametersContainer, simulator,
name,
ParameterFloat.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getStringParameterParametersContainer")
Expand All @@ -791,7 +791,7 @@ public String getStringParameter(ParametersContainer parametersContainer,
ParameterString par = getParameterByNameAndType(parametersContainer, simulator,
name,
ParameterString.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getIntegerParameterParametersContainer")
Expand All @@ -800,7 +800,7 @@ public Integer getIntegerParameter(ParametersContainer parametersContainer,
ParameterInteger par = getParameterByNameAndType(parametersContainer, simulator,
name,
ParameterInteger.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getBooleanParameterParametersContainer")
Expand All @@ -809,7 +809,7 @@ public Boolean getBooleanParameter(ParametersContainer parametersContainer,
ParameterBoolean par = getParameterByNameAndType(parametersContainer, simulator,
name,
ParameterBoolean.class);
return ((par != null) ? (par.getValue()) : null);
return (par != null) ? (par.getValue()) : null;
}

@WebMethod(operationName = "getTableParameterParametersContainer")
Expand All @@ -819,7 +819,7 @@ public ParameterTable getTableParameter(ParametersContainer parametersContainer,
ParameterTable par = getParameterByNameAndType(parametersContainer, simulator,
name,
ParameterTable.class);
return ((par != null) ? (par) : null);
return (par != null) ? par : null;
}

@WebMethod(operationName = "saveConnectionSchema")
Expand Down Expand Up @@ -851,7 +851,7 @@ public ConnectionSchema findConnectionSchema(String cimId,
query.setParameter("arg2", simulator);
}
List<ConnectionSchema> res = query.getResultList();
return (res.size() > 0 ? res.get(0) : null);
return res.size() > 0 ? res.get(0) : null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ private void processConnections(DDBManager ddbmanager) {
String id2 = EquipmentsInternalsMap.get(nativeId).get(j);
Set<String> intSet = Sets.intersection(Sets.newHashSet(macroblocksPinNames.get(id1)), Sets.newHashSet(macroblocksPinNames.get(id2)));
log.debug("--- reg: " + id1 + ", reg: " + id2 + ", common variable names:" + intSet);
boolean toBeProcessed = (intSet.size() > 0);
boolean toBeProcessed = intSet.size() > 0;
if (toBeProcessed) {
for (String pinName : intSet) {
String longId1 = nativeId + "_" + id1;
Expand Down

0 comments on commit 5b9aa7e

Please sign in to comment.