Skip to content

Commit fddee3e

Browse files
committed
Lib java decompiler
1 parent c6186e1 commit fddee3e

File tree

88 files changed

+18525
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+18525
-0
lines changed

lib-decompiler/build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion rootProject.ext.compileSdkVersion
5+
buildToolsVersion rootProject.ext.buildToolsVersion
6+
7+
defaultConfig {
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
23+
compileOptions {
24+
targetCompatibility 1.7
25+
sourceCompatibility 1.7
26+
}
27+
}
28+
dependencies {
29+
testImplementation 'junit:junit:4.12'
30+
testImplementation 'org.assertj:assertj-core:3.10.0'
31+
api fileTree(dir: 'libs', include: ['*.jar'])
32+
}
33+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<manifest package="com.duy.ide.java.plugin.decompiler" />
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.duy.java8.util;
2+
3+
import com.duy.java8.util.function.Predicate;
4+
5+
import java.util.Iterator;
6+
7+
public class DCollection {
8+
public static <E> boolean removeIf(java.util.Collection<E> collection,
9+
Predicate<? super E> filter) {
10+
boolean removed = false;
11+
final Iterator<E> each = collection.iterator();
12+
while (each.hasNext()) {
13+
if (filter.test(each.next())) {
14+
each.remove();
15+
removed = true;
16+
}
17+
}
18+
return removed;
19+
}
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.duy.java8.util;
2+
3+
import java.util.Comparator;
4+
5+
public class DComparator {
6+
public static <T> Comparator<T> thenComparing(final Comparator<? super T> first,
7+
final Comparator<? super T> second) {
8+
return new Comparator<T>() {
9+
@Override
10+
public int compare(T c1, T c2) {
11+
int res = first.compare(c1, c2);
12+
return (res != 0) ? res : second.compare(c1, c2);
13+
}
14+
};
15+
}
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.duy.java8.util;
2+
3+
import com.duy.java8.util.function.Consumer;
4+
import com.duy.java8.util.function.Predicate;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
public class DList {
10+
public static <E> void forEach(List<E> list, Consumer<? super E> action) {
11+
for (E e : list) {
12+
action.accept(e);
13+
}
14+
}
15+
16+
public static <E> List<E> filter(List<E> input, Predicate<E> predicate) {
17+
List<E> list = new ArrayList<>();
18+
for (E e : input) {
19+
if (predicate.test(e)) {
20+
list.add(e);
21+
}
22+
}
23+
return list;
24+
}
25+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.duy.java8.util;
2+
3+
import com.duy.java8.util.function.BiFunction;
4+
import com.duy.java8.util.function.Function;
5+
6+
import java.util.Map;
7+
8+
public class DMap {
9+
public static <K, V> V putIfAbsent(Map<K, V> map, K key, V value) {
10+
V v = map.get(key);
11+
if (v == null) {
12+
v = map.put(key, value);
13+
}
14+
15+
return v;
16+
}
17+
18+
public static <K, V> V computeIfAbsent(Map<K, V> map, K key,
19+
Function<? super K, ? extends V> mappingFunction) {
20+
V v;
21+
if ((v = map.get(key)) == null) {
22+
V newValue;
23+
if ((newValue = mappingFunction.apply(key)) != null) {
24+
map.put(key, newValue);
25+
return newValue;
26+
}
27+
}
28+
29+
return v;
30+
}
31+
32+
public static <K, V> V merge(Map<K, V> map, K key, V value,
33+
BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
34+
V oldValue = map.get(key);
35+
V newValue = (oldValue == null) ? value :
36+
remappingFunction.apply(oldValue, value);
37+
if (newValue == null) {
38+
map.remove(key);
39+
} else {
40+
map.put(key, newValue);
41+
}
42+
return newValue;
43+
}
44+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.duy.java8.util.function;
26+
27+
/**
28+
* Represents a function that accepts two arguments and produces a result.
29+
* This is the two-arity specialization of {@link com.duy.java8.util.function.Function}.
30+
* <p>
31+
* <p>This is a <a href="package-summary.html">functional interface</a>
32+
* whose functional method is {@link #apply(Object, Object)}.
33+
*
34+
* @param <T> the type of the first argument to the function
35+
* @param <U> the type of the second argument to the function
36+
* @param <R> the type of the result of the function
37+
* @see com.duy.java8.util.function.Function
38+
*/
39+
public interface BiFunction<T, U, R> {
40+
41+
/**
42+
* Applies this function to the given arguments.
43+
*
44+
* @param t the first function argument
45+
* @param u the second function argument
46+
* @return the function result
47+
*/
48+
R apply(T t, U u);
49+
50+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.duy.java8.util.function;
26+
27+
28+
/**
29+
* Represents an operation upon two operands of the same type, producing a result
30+
* of the same type as the operands. This is a specialization of
31+
* {@link com.duy.java8.util.function.BiFunction} for the case where the operands and the result are all of
32+
* the same type.
33+
* <p>
34+
* <p>This is a <a href="package-summary.html">functional interface</a>
35+
* whose functional method is {@link #apply(Object, Object)}.
36+
*
37+
* @param <T> the type of the operands and result of the operator
38+
* @see com.duy.java8.util.function.BiFunction
39+
* @see UnaryOperator
40+
*/
41+
@FunctionalInterface
42+
public interface BinaryOperator<T> extends BiFunction<T, T, T> {
43+
44+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.duy.java8.util.function;
26+
27+
/**
28+
* Represents an operation that accepts a single input argument and returns no
29+
* result. Unlike most other functional interfaces, {@code Consumer} is expected
30+
* to operate via side-effects.
31+
* <p>
32+
* <p>This is a <a href="package-summary.html">functional interface</a>
33+
* whose functional method is {@link #accept(Object)}.
34+
*
35+
* @param <T> the type of the input to the operation
36+
*/
37+
public interface Consumer<T> {
38+
39+
/**
40+
* Performs this operation on the given argument.
41+
*
42+
* @param t the input argument
43+
*/
44+
void accept(T t);
45+
46+
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
package com.duy.java8.util.function;
26+
27+
/**
28+
* Represents a function that accepts one argument and produces a result.
29+
* <p>
30+
* <p>This is a <a href="package-summary.html">functional interface</a>
31+
* whose functional method is {@link #apply(Object)}.
32+
*
33+
* @param <T> the type of the input to the function
34+
* @param <R> the type of the result of the function
35+
*/
36+
public interface Function<T, R> {
37+
38+
/**
39+
* Applies this function to the given argument.
40+
*
41+
* @param t the function argument
42+
* @return the function result
43+
*/
44+
R apply(T t);
45+
46+
47+
}

0 commit comments

Comments
 (0)