From 8606ef44cac8f855ede8ae6e9b5681a9c8f28139 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 8 Jan 2017 00:11:58 +0800 Subject: [PATCH] Make sure that method signature for Integer getModelIndex() is exactly the same, otherwise the class file may include two method signature for exactly the same method, and differences with annotations in the output class files in the Eclipse and Oracle javac can lead to unexpected bugs and changes in behavior from development to deployment. Scary! --- source/net/filebot/format/ExpressionBindings.java | 3 ++- source/net/filebot/format/MediaBindingBean.java | 8 ++++---- source/net/filebot/ui/list/IndexedBindingBean.java | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/net/filebot/format/ExpressionBindings.java b/source/net/filebot/format/ExpressionBindings.java index 8ec547ec..354c66b0 100644 --- a/source/net/filebot/format/ExpressionBindings.java +++ b/source/net/filebot/format/ExpressionBindings.java @@ -30,8 +30,9 @@ public class ExpressionBindings extends AbstractMap implements B for (String name : define.value()) { Method existingBinding = bindings.put(name, method); - if (existingBinding != null) + if (existingBinding != null) { throw new IllegalArgumentException(String.format("Illegal binding {%s} on %s", name, method.getName())); + } } } } diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index 8ba03030..b3a12607 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -953,18 +953,18 @@ public class MediaBindingBean { } @Define("i") - public Number getModelIndex() { + public Integer getModelIndex() { return 1 + identityIndexOf(context.values(), getInfoObject()); } @Define("di") - public Number getDuplicateIndex() { + public Integer getDuplicateIndex() { return 1 + identityIndexOf(context.values().stream().filter(getInfoObject()::equals).collect(toList()), getInfoObject()); } @Define("dc") - public Number getDuplicateCount() { - return context.values().stream().filter(getInfoObject()::equals).count(); + public Integer getDuplicateCount() { + return context.values().stream().filter(getInfoObject()::equals).mapToInt(i -> 1).sum(); } @Define("plex") diff --git a/source/net/filebot/ui/list/IndexedBindingBean.java b/source/net/filebot/ui/list/IndexedBindingBean.java index 170a461b..341ef87c 100644 --- a/source/net/filebot/ui/list/IndexedBindingBean.java +++ b/source/net/filebot/ui/list/IndexedBindingBean.java @@ -24,6 +24,7 @@ public class IndexedBindingBean extends MediaBindingBean { this.to = to; } + @Override @Define("i") public Integer getModelIndex() { return i;