OSDN Git Service

リファクタリング
authoryukihane <yukihane.feather@gmail.com>
Wed, 21 Sep 2011 07:05:12 +0000 (16:05 +0900)
committeryukihane <yukihane.feather@gmail.com>
Wed, 21 Sep 2011 17:42:00 +0000 (02:42 +0900)
frontend/src/saccubus/conv/NicoXMLReader.java

index 89409bf..7fbea65 100644 (file)
@@ -61,6 +61,22 @@ public class NicoXMLReader extends DefaultHandler {
             this.optional = optional;
         }
 
+        static ProcessType valueOf(boolean owner, boolean optional) {
+            if (!optional) {
+                if (!owner) {
+                    return NORMAL;
+                } else {
+                    return OWNER;
+                }
+            } else {
+                if (!owner) {
+                    return OPTIONAL;
+                } else {
+                    return OPTIONAL_OWNER;
+                }
+            }
+        }
+
         boolean isOwner() {
             return owner;
         }
@@ -178,21 +194,14 @@ public class NicoXMLReader extends DefaultHandler {
             final boolean isOwner = "1".equals(fork);
             final String th = attributes.getValue("thread");
 
-            // 初めて見つけたthreadをメインスレッドとみなす
-            if(mainThreadId == null) {
+            // 初めて見つけたthreadをメインスレッド(非オプショナルスレッド)とみなす
+            if (mainThreadId == null) {
                 mainThreadId = th;
             }
 
             final boolean isOptional = (mainThreadId == null) ? false : !mainThreadId.equals(th);
 
-            boolean nokick = false;
-            for(ProcessType pt : processTypes) {
-                if(pt.isOwner() == isOwner && pt.isOptional() == isOptional) {
-                    nokick = true;
-                    break;
-                }
-            }
-            if(!nokick) {
+            if(!processTypes.contains(ProcessType.valueOf(isOwner, isOptional))){
                 itemKicked = true;
                 return;
             }