Skip to content

Commit

Permalink
feat(#269): fix all qulice suggestiosn
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Nov 21, 2023
1 parent 64bab3c commit e837d98
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/main/java/org/eolang/jeo/Details.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public class Details {
/**
* Name of the class or an object.
*/
private static final String NAME = "name";
private static final String NAME_KEY = "name";

/**
* Original source of the representation.
* Might be a file name or a URL:
* - Application.java
* - Application.xmir
*/
private static final String SOURCE = "source";
private static final String SOURCE_KEY = "source";

/**
* Storage with all the details.
Expand All @@ -57,7 +57,7 @@ public class Details {
* @param source Original source of the representation.
*/
public Details(final String name, final String source) {
this(Details.NAME, name, Details.SOURCE, source);
this(Details.NAME_KEY, name, Details.SOURCE_KEY, source);
}

/**
Expand Down Expand Up @@ -89,7 +89,7 @@ private Details(final Map<String, String> storage) {
* @return Name.
*/
public String name() {
return this.storage.get(Details.NAME);
return this.storage.get(Details.NAME_KEY);
}

/**
Expand All @@ -98,22 +98,22 @@ public String name() {
* @return Source.
*/
public String source() {
return this.storage.get(Details.SOURCE);
return this.storage.get(Details.SOURCE_KEY);
}

/**
* Initializations.
* @param pairs Pairs of key-value.
* @return Map with all the details.
*/
private static Map<String, String> initial(String... pairs) {
private static Map<String, String> initial(final String... pairs) {
final int length = pairs.length;
if (length % 2 == 1) {
throw new IllegalArgumentException("Must have an even number of arguments");
}
Map<String, String> map = new HashMap<>(pairs.length / 2);
for (int i = 0; i < length; i += 2) {
map.put(pairs[i], pairs[i + 1]);
final Map<String, String> map = new HashMap<>(pairs.length / 2);
for (int index = 0; index < length; index += 2) {
map.put(pairs[index], pairs[index + 1]);
}
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public BytecodeRepresentation(final Path clazz) {
this(new InputOf(clazz), clazz.getFileName().toString());
}

/**
* Constructor.
* @param bytecode Bytecode
*/
public BytecodeRepresentation(final Bytecode bytecode) {
this(bytecode.asBytes());
}
Expand All @@ -85,6 +89,7 @@ public BytecodeRepresentation(final Bytecode bytecode) {
/**
* Constructor.
* @param input Input source
* @param source The source of the input
*/
private BytecodeRepresentation(final Input input, final String source) {
this(new UncheckedBytes(new BytesOf(input)).asBytes(), source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ public final class EoRepresentation implements Representation {
*/
private final XML xml;

/**
* Source of the XML.
*/
private final String source;

/**
* Constructor.
* @param path Path to XML file.
*/
public EoRepresentation(final Path path) {
this(EoRepresentation.xml(path), path.getFileName().toString());
this(EoRepresentation.open(path), path.getFileName().toString());
}

/**
Expand Down Expand Up @@ -114,7 +121,7 @@ public Bytecode toBytecode() {
* @param path Path to XML file.
* @return XML.
*/
private static XML xml(final Path path) {
private static XML open(final Path path) {
try {
return new XMLDocument(path.toFile());
} catch (final FileNotFoundException exception) {
Expand Down

1 comment on commit e837d98

@0pdd
Copy link

@0pdd 0pdd commented on e837d98 Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 269-0fbbc9a3 discovered in src/main/java/org/eolang/jeo/Representation.java) and submitted as #279. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.