Skip to content

Commit

Permalink
Extracting conditional methods for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
LadDeep committed Apr 7, 2023
1 parent f691e4b commit 50e9439
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/picard/illumina/MarkIlluminaAdapters.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,17 @@ public class MarkIlluminaAdapters extends CommandLineProgram {

@Override
protected String[] customCommandLineValidation() {
if ((FIVE_PRIME_ADAPTER != null && THREE_PRIME_ADAPTER == null) || (THREE_PRIME_ADAPTER != null && FIVE_PRIME_ADAPTER == null)) {
if (hasEitherAdapter()) {
return new String[]{"THREE_PRIME_ADAPTER and FIVE_PRIME_ADAPTER must either both be null or both be set."};
} else {
return null;
}
}

private boolean hasEitherAdapter() {
return (FIVE_PRIME_ADAPTER != null && THREE_PRIME_ADAPTER == null) || (THREE_PRIME_ADAPTER != null && FIVE_PRIME_ADAPTER == null);
}

@Override
protected int doWork() {
IOUtil.assertFileIsReadable(INPUT);
Expand All @@ -167,7 +171,7 @@ protected int doWork() {
{
final List<AdapterPair> tmp = new ArrayList<AdapterPair>();
tmp.addAll(ADAPTERS);
if (FIVE_PRIME_ADAPTER != null && THREE_PRIME_ADAPTER != null) {
if (hasBothAdapters()) {
tmp.add(new CustomAdapterPair(FIVE_PRIME_ADAPTER, THREE_PRIME_ADAPTER));
}
adapters = tmp.toArray(new AdapterPair[tmp.size()]);
Expand Down Expand Up @@ -246,4 +250,8 @@ protected int doWork() {
CloserUtil.close(in);
return 0;
}

private boolean hasBothAdapters(){
return FIVE_PRIME_ADAPTER != null && THREE_PRIME_ADAPTER != null;
}
}

0 comments on commit 50e9439

Please sign in to comment.