77import java .lang .annotation .Retention ;
88import java .lang .annotation .RetentionPolicy ;
99import java .lang .annotation .Target ;
10- import java .util .Map ;
11- import java .util .concurrent .ConcurrentHashMap ;
1210
1311/**
1412 * <pre>
2220 */
2321public final class BusUtils {
2422
25- private static final Object NULL = new Object ();
26- private static final Map <Object , String > BUSES = new ConcurrentHashMap <>();
23+ private static final Object NULL = new Object ();
2724
2825 public static <T > T post (final String name , final Object ... objects ) {
2926 if (name == null || name .length () == 0 ) return null ;
@@ -35,17 +32,6 @@ public static <T> T post(final String name, final Object... objects) {
3532 return (T ) o ;
3633 }
3734
38-
39- public static void register (final Object bus ) {
40-
41- }
42-
43- public static void unregister (final Object bus ) {
44-
45- }
46-
47-
48-
4935 private static Object injectShell (final String name , final Object [] objects ) {
5036 return NULL ;
5137 }
@@ -54,5 +40,76 @@ private static Object injectShell(final String name, final Object[] objects) {
5440 @ Retention (RetentionPolicy .CLASS )
5541 public @interface Subscribe {
5642 String name () default "" ;
43+
44+ int priority () default 0 ;
5745 }
46+
47+ // private static final Map<String, TreeSet<Bus>> BUSES = new ConcurrentHashMap<>();
48+
49+ // public static void register(final Object bus) {
50+ // Class c = null;
51+ // if (bus.getClass().equals(c)) {
52+ //
53+ // }
54+ // }
55+
56+ // public static void unregister(final Object bus) {
57+ // if (bus == null) return;
58+ // Class busClass = bus.getClass();
59+ // if (BUSES.containsKey(busClass)) {
60+ //
61+ // }
62+ // }
63+
64+ // private static Object inject(final String name, int priority ){
65+ // if (!BUSES.containsKey(name)) return NULL;
66+ // TreeSet<Bus> buses = BUSES.get(name);
67+ // for (Bus bus : buses) {
68+ // bus.
69+ // }
70+ // return NULL;
71+ // }
72+
73+ // static class Bus implements Comparable<Bus> {
74+ //
75+ // TreeMap<Object, Integer> mTreeMap;
76+ //
77+ // Bus(Object object) {
78+ // this(object, 0);
79+ // }
80+ //
81+ // Bus(Object object, int priority) {
82+ // mTreeMap = new TreeMap<>();
83+ // this.priority = priority;
84+ // }
85+ //
86+ // @Override
87+ // public int compareTo(@NonNull Bus o) {
88+ // return (this.priority < o.priority) ? 1 : ((this.priority == o.priority) ? 0 : -1);
89+ // }
90+ //
91+ // @Override
92+ // public boolean equals(Object obj) {
93+ // return ObjectUtils.equals(this, obj);
94+ // }
95+ //
96+ // @Override
97+ // public String toString() {
98+ // return mObject.toString() + ": " + priority;
99+ // }
100+ // }
101+ //
102+ // public static void main(String[] args) {
103+ // TreeSet<Bus> queue = new TreeSet<>();
104+ // Bus bus0 = new Bus("", 1);
105+ // Bus bus1 = new Bus("", 2);
106+ // Bus bus2 = new Bus("", 3);
107+ // Bus bus3 = new Bus("", 3);
108+ // queue.add(bus1);
109+ // queue.add(bus2);
110+ // queue.add(bus0);
111+ //
112+ // System.out.println(queue);
113+ //
114+ // }
58115}
0 commit comments