Quellcode durchsuchen

添加{}使代码更容易理解

Sxile vor 5 Jahren
Ursprung
Commit
2c250c1d1b

+ 12 - 6
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ip/IpUtils.java

@@ -110,8 +110,9 @@ public class IpUtils
110 110
             {
111 111
                 case 1:
112 112
                     l = Long.parseLong(elements[0]);
113
-                    if ((l < 0L) || (l > 4294967295L))
113
+                    if ((l < 0L) || (l > 4294967295L)){
114 114
                         return null;
115
+                    }
115 116
                     bytes[0] = (byte) (int) (l >> 24 & 0xFF);
116 117
                     bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
117 118
                     bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
@@ -119,12 +120,14 @@ public class IpUtils
119 120
                     break;
120 121
                 case 2:
121 122
                     l = Integer.parseInt(elements[0]);
122
-                    if ((l < 0L) || (l > 255L))
123
+                    if ((l < 0L) || (l > 255L)) {
123 124
                         return null;
125
+                    }
124 126
                     bytes[0] = (byte) (int) (l & 0xFF);
125 127
                     l = Integer.parseInt(elements[1]);
126
-                    if ((l < 0L) || (l > 16777215L))
128
+                    if ((l < 0L) || (l > 16777215L)) {
127 129
                         return null;
130
+                    }
128 131
                     bytes[1] = (byte) (int) (l >> 16 & 0xFF);
129 132
                     bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
130 133
                     bytes[3] = (byte) (int) (l & 0xFF);
@@ -133,13 +136,15 @@ public class IpUtils
133 136
                     for (i = 0; i < 2; ++i)
134 137
                     {
135 138
                         l = Integer.parseInt(elements[i]);
136
-                        if ((l < 0L) || (l > 255L))
139
+                        if ((l < 0L) || (l > 255L)) {
137 140
                             return null;
141
+                        }
138 142
                         bytes[i] = (byte) (int) (l & 0xFF);
139 143
                     }
140 144
                     l = Integer.parseInt(elements[2]);
141
-                    if ((l < 0L) || (l > 65535L))
145
+                    if ((l < 0L) || (l > 65535L)) {
142 146
                         return null;
147
+                    }
143 148
                     bytes[2] = (byte) (int) (l >> 8 & 0xFF);
144 149
                     bytes[3] = (byte) (int) (l & 0xFF);
145 150
                     break;
@@ -147,8 +152,9 @@ public class IpUtils
147 152
                     for (i = 0; i < 4; ++i)
148 153
                     {
149 154
                         l = Integer.parseInt(elements[i]);
150
-                        if ((l < 0L) || (l > 255L))
155
+                        if ((l < 0L) || (l > 255L)) {
151 156
                             return null;
157
+                        }
152 158
                         bytes[i] = (byte) (int) (l & 0xFF);
153 159
                     }
154 160
                     break;