source: java/main/src/main/java/com/framsticks/util/Misc.java @ 102

Last change on this file since 102 was 102, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

for Joinables running

CHANGELOG:
Add WorkPackageLogic? and classes representing prime experiment state.

Add classes for PrimeExperiment? state.

Extract single netload routine in Simulator.

Working netload with dummy content in PrimeExperiment?.

More development with NetLoadSaveLogic? and PrimeExperiment?.

Improvement around prime.

Improve BufferedDispatcher?.isActive logic.

Add prime-all.xml configuration.

Manual connecting to existing simulators from GUI.

Guard in SimulatorConnector? against expdef mismatch.

Guard against empty target dispatcher in BufferedDispatcher?.

Make BufferedDispatcher? a Dispatcher (and Joinable).

Minor improvements.

Done StackedJoinable?, improve Experiment.

Develop StackedJoinable?.

Add StackedJoinable? utility joinables controller.

Add dependency on apache-commons-lang.

Add ready ListChange? on Simulators.

Improve hints in ListChange?.

Several improvements.

Found bug with dispatching in Experiment.

Minor improvements.

Fix bug with early finishing Server.

Many changes in Dispatching.

Fix bug with connection.

Do not obfuscate log with socket related exceptions.

Add SocketClosedException?.

Add SimulatorConnector?.

Work out conception of experiment composing of logics building blocks.

Rename SinkInterface? to Sink.

Move saving of Accesses into AccessOperations?.

Some improvements to Experiment.

Improve joinables.

Fix issue with joinables closing.

Add direct and managed consoles to popup menu.

File size: 1.3 KB
Line 
1package com.framsticks.util;
2
3// import org.apache.logging.log4j.Logger;
4
5/**
6 * Author: Piotr Śniegowski
7 */
8public class Misc {
9        // private static final Logger log =
10        //      LogManager.getLogger(Misc.class);
11
12        public static class WithType {
13                protected Object value;
14
15                /**
16                 * @param value
17                 */
18                public WithType(Object value) {
19                        this.value = value;
20                }
21
22                @Override
23                public String toString() {
24                        if (value == null) {
25                                return "null";
26                        }
27                        return value + "(" + value.getClass() + ")";
28                }
29        }
30
31        public static WithType withType(Object value) {
32                return new WithType(value);
33        }
34
35        public static boolean equals(Object a, Object b) {
36                // log.info("equality of {} ? {}", withType(a), withType(b));
37                if (a != null) {
38                        return (b != null && a.equals(b));
39                }
40                return b == null;
41        }
42
43        public static <T> T returnNotNull(T first, T second) {
44                if (first != null) {
45                        return first;
46                }
47                return second;
48        }
49
50        public static <T> T throwIfNull(T value) {
51                if (value == null) {
52                        throw new FramsticksException().msg("value should not be null");
53                }
54                return value;
55        }
56
57        public static void checkEquals(Object expected, Object found, String message, Object context) {
58                if (equals(expected, found)) {
59                        return;
60                }
61                throw new FramsticksException().msg(message).arg("expected", expected).arg("found", found).arg("in", context);
62        }
63}
Note: See TracBrowser for help on using the repository browser.