Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Reduce scope of members (#1)
Browse files Browse the repository at this point in the history
* Reduce scope of members for issue #214

* Adjusted some of the scopes

IntelliJ was a bit too aggressive in its refactoring

* Fixed additional issues

* More Fixes
  • Loading branch information
macdude357 authored and tpedone1 committed Oct 24, 2019
1 parent a2941e0 commit 52c8678
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private static class XFormParserWithBindEnhancements extends XFormParser {
private Document xmldoc;
private BaseFormParserForJavaRosa parser;

public XFormParserWithBindEnhancements(BaseFormParserForJavaRosa parser, Document form) {
private XFormParserWithBindEnhancements(BaseFormParserForJavaRosa parser, Document form) {
super(form);
this.xmldoc = form;
this.parser = parser;
Expand All @@ -215,17 +215,17 @@ private static synchronized final XFormParserWithBindEnhancements parseFormDefin
* The ODK Id that uniquely identifies the form
*/
public transient final FormDef rootJavaRosaFormDef;
protected final XFormParameters rootElementDefn;
private final XFormParameters rootElementDefn;
protected transient final TreeElement trueSubmissionElement;
protected transient final TreeElement submissionElement;
private transient final TreeElement submissionElement;
protected final XFormParameters submissionElementDefn;
protected final String base64RsaPublicKey;
private final String base64RsaPublicKey;
protected final boolean isFileEncryptedForm;
protected final boolean isNotUploadableForm;
protected final boolean isInvalidFormXmlns; // legacy 0.9.8 form
private final boolean isNotUploadableForm;
private final boolean isInvalidFormXmlns; // legacy 0.9.8 form
protected final String title;
protected final boolean isFieldEncryptedForm;
protected final String base64EncryptedFieldRsaPublicKey;
private final String base64EncryptedFieldRsaPublicKey;

/**
* The XForm definition in XML
Expand Down Expand Up @@ -526,7 +526,7 @@ private void printTreeElementInfo(TreeElement treeElement) {
+ " repeatable: " + treeElement.isRepeatable());
}

public String getTreeElementPath(AbstractTreeElement<?> e) {
private String getTreeElementPath(AbstractTreeElement<?> e) {
if (e == null)
return null;
String s = getTreeElementPath(e.getParent());
Expand Down Expand Up @@ -555,10 +555,6 @@ private List<Element> getBindingsForTreeElement(TreeElement treeElement) {
return (l);
}

public String getFormId() {
return rootElementDefn.formId;
}

/**
* Compare two XML files to assess their level of structural difference (if
* any).
Expand Down
6 changes: 3 additions & 3 deletions src/org/opendatakit/briefcase/export/ExportConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class ExportConfiguration {
private final OverridableBoolean removeGroupNames;
private final OverridableBoolean smartAppend;

public ExportConfiguration(Optional<String> exportFileName, Optional<Path> exportDir, Optional<Path> pemFile, DateRange dateRange, OverridableBoolean pullBefore, OverridableBoolean overwriteFiles, OverridableBoolean exportMedia, OverridableBoolean splitSelectMultiples, OverridableBoolean includeGeoJsonExport, OverridableBoolean removeGroupNames, OverridableBoolean smartAppend) {
private ExportConfiguration(Optional<String> exportFileName, Optional<Path> exportDir, Optional<Path> pemFile, DateRange dateRange, OverridableBoolean pullBefore, OverridableBoolean overwriteFiles, OverridableBoolean exportMedia, OverridableBoolean splitSelectMultiples, OverridableBoolean includeGeoJsonExport, OverridableBoolean removeGroupNames, OverridableBoolean smartAppend) {
this.exportFileName = exportFileName;
this.exportDir = exportDir;
this.pemFile = pemFile;
Expand Down Expand Up @@ -338,7 +338,7 @@ public int hashCode() {
}

public static class Builder {
public static final Consumer<String> NO_OP = __ -> { };
private static final Consumer<String> NO_OP = __ -> { };
private String exportFilename;
private Path exportDir;
private Path pemFile;
Expand Down Expand Up @@ -405,7 +405,7 @@ public ExportConfiguration build() {
public Builder setExportFilename(String fileName) {
return setExportFilename(Optional.ofNullable(fileName));
}

public Builder setExportFilename(Optional<String> fileName) {
exportFilename = fileName.orElse(null);
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/org/opendatakit/briefcase/export/FormDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static FormDefinition from(BriefcaseFormDefinition briefcaseFormDefinitio
briefcaseFormDefinition.getFormName(),
briefcaseFormDefinition.isFileEncryptedForm(),
// TODO Improve getting the FormDef out of the BriefcaseFormDefinition
new Model(briefcaseFormDefinition.getSubmissionElement(), getFormControls(briefcaseFormDefinition.formDefn.rootJavaRosaFormDef))
new Model(briefcaseFormDefinition.getSubmissionElement(), getFormControls(briefcaseFormDefinition.getFormDefn().rootJavaRosaFormDef))
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/org/opendatakit/briefcase/export/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* It can hold the root level model or any of its fields.
*/
class Model {
final TreeElement model;
private final TreeElement model;
private Map<String, QuestionDef> controls;

/**
Expand Down Expand Up @@ -339,7 +339,7 @@ enum ControlType {
* @param intControlType the int value of the requested DataType
* @return the related {@link ControlType} instance
*/
public static ControlType from(int intControlType) {
static ControlType from(int intControlType) {
for (ControlType ct : values()) {
if (ct.value == intControlType)
return ct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class BriefcaseFormDefinition implements IFormDefinition, Serializable {
private final File formFolder;
private final File revisedFormFile;
private boolean needsMediaUpdate;
public JavaRosaParserWrapper formDefn;
private JavaRosaParserWrapper formDefn;

private static String readFile(File formDefinitionFile) throws BadFormDefinition {
StringBuilder xmlBuilder = new StringBuilder();
Expand Down Expand Up @@ -303,6 +303,10 @@ public String toString() {
public File getFormDirectory() {
return formFolder;
}

public JavaRosaParserWrapper getFormDefn() {
return formDefn;
}

@Override
public String getFormName() {
Expand Down
4 changes: 2 additions & 2 deletions src/org/opendatakit/briefcase/model/BriefcasePreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public BriefcasePreferences(Preferences preferences) {
this.preferences = preferences;
}

private BriefcasePreferences(Class<?> node, PreferenceScope scope) {
public BriefcasePreferences(Class<?> node, PreferenceScope scope) {
this.node = node;
this.preferences = scope.preferenceFactory(node);
}
Expand Down Expand Up @@ -259,7 +259,7 @@ public Preferences preferenceFactory(Class<?> node) {
}
};

public abstract Preferences preferenceFactory(Class<?> node);
protected abstract Preferences preferenceFactory(Class<?> node);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/org/opendatakit/briefcase/model/TerminationFuture.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void markAsCancelled(PushEvent.Cancel event) {
@EventSubscriber(eventClass = PullEvent.Cancel.class)
public void markAsCancelled(PullEvent.Cancel event) {
cancelled = true;
log.info("cancel requested: " + event.cause);
log.info("cancel requested: " + event.getCause());
}

public void reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
package org.opendatakit.briefcase.model;

public class UpdatedBriefcaseFormDefinitionEvent {
public final BriefcaseFormDefinition definition;
private final BriefcaseFormDefinition definition;

UpdatedBriefcaseFormDefinitionEvent(BriefcaseFormDefinition definition) {
this.definition = definition;
}

public BriefcaseFormDefinition getDefinition() {
return this.definition;
}
}
26 changes: 21 additions & 5 deletions src/org/opendatakit/briefcase/pull/PullEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,29 @@
public class PullEvent {

public static class Success extends PullEvent {
public final FormStatus form;
public final Optional<RemoteServer> remoteServer;
public final Optional<Cursor> lastCursor;
private final FormStatus form;
private final Optional<RemoteServer> remoteServer;
private final Optional<Cursor> lastCursor;

private Success(FormStatus form, Optional<RemoteServer> remoteServer, Optional<Cursor> lastCursor) {
this.form = form;
this.remoteServer = remoteServer;
this.lastCursor = lastCursor;
}

public static Success of(FormStatus form) {
public FormStatus getForm() {
return form;
}

public Optional<RemoteServer> getRemoteServer() {
return remoteServer;
}

public Optional<Cursor> getLastCursor() {
return lastCursor;
}

public static Success of(FormStatus form) {
return new Success(form, Optional.empty(), Optional.empty());
}

Expand All @@ -53,11 +65,15 @@ public void ifRemoteServer(BiConsumer<FormStatus, RemoteServer> consumer) {
}

public static class Cancel extends PullEvent {
public final String cause;
private final String cause;

public Cancel(String cause) {
this.cause = cause;
}

public String getCause() {
return this.cause;
}
}

public static class CleanAllResumePoints extends PullEvent {
Expand Down
4 changes: 2 additions & 2 deletions src/org/opendatakit/briefcase/reused/http/CommonsHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ private <T> Response<T> uncheckedExecute(Request<T> request, Executor executor)
MultipartEntityBuilder bodyBuilder = MultipartEntityBuilder.create();
for (MultipartMessage part : request.multipartMessages)
bodyBuilder = bodyBuilder.addPart(
part.name,
new InputStreamBody(part.body, ContentType.create(part.contentType), part.attachmentName)
part.getName(),
new InputStreamBody(part.getBody(), ContentType.create(part.getContentType()), part.getAttachmentName())
);
body = bodyBuilder.build();
} else {
Expand Down
24 changes: 20 additions & 4 deletions src/org/opendatakit/briefcase/reused/http/MultipartMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import java.util.Objects;

public class MultipartMessage {
final String name;
final String contentType;
final String attachmentName;
final InputStream body;
private final String name;
private final String contentType;
private final String attachmentName;
private final InputStream body;

MultipartMessage(String name, String contentType, String attachmentName, InputStream body) {
this.name = name;
Expand All @@ -32,6 +32,22 @@ public class MultipartMessage {
this.body = body;
}

public String getName() {
return name;
}

public String getContentType() {
return contentType;
}

public String getAttachmentName() {
return attachmentName;
}

public InputStream getBody() {
return body;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

public class CentralServerDialog {
private static final Logger log = LoggerFactory.getLogger(CentralServerDialog.class);
final CentralServerDialogForm form;
private final CentralServerDialogForm form;
private final List<Consumer<CentralServer>> onConnectCallbacks = new ArrayList<>();

private CentralServerDialog(CentralServerDialogForm form, Test<CentralServer> serverTester) {
Expand Down

0 comments on commit 52c8678

Please sign in to comment.