Flutter Engine
The Flutter Engine
FoldingRegion.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file.
5 *
6 * This file has been automatically generated. Please do not edit it manually.
7 * To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files".
8 */
9package org.dartlang.analysis.server.protocol;
10
11import java.util.Arrays;
12import java.util.List;
13import java.util.Map;
14import com.google.common.collect.Lists;
15import com.google.dart.server.utilities.general.JsonUtilities;
16import com.google.dart.server.utilities.general.ObjectUtilities;
17import com.google.gson.JsonArray;
18import com.google.gson.JsonElement;
19import com.google.gson.JsonObject;
20import com.google.gson.JsonPrimitive;
21import org.apache.commons.lang3.builder.HashCodeBuilder;
22import java.util.ArrayList;
23import java.util.Iterator;
24import org.apache.commons.lang3.StringUtils;
25
26/**
27 * A description of a region that can be folded.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class FoldingRegion {
33
34 public static final FoldingRegion[] EMPTY_ARRAY = new FoldingRegion[0];
35
36 public static final List<FoldingRegion> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The kind of the region.
40 */
41 private final String kind;
42
43 /**
44 * The offset of the region to be folded.
45 */
46 private final int offset;
47
48 /**
49 * The length of the region to be folded.
50 */
51 private final int length;
52
53 /**
54 * Constructor for {@link FoldingRegion}.
55 */
56 public FoldingRegion(String kind, int offset, int length) {
57 this.kind = kind;
58 this.offset = offset;
59 this.length = length;
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (obj instanceof FoldingRegion) {
65 FoldingRegion other = (FoldingRegion) obj;
66 return
67 ObjectUtilities.equals(other.kind, kind) &&
68 other.offset == offset &&
69 other.length == length;
70 }
71 return false;
72 }
73
74 public static FoldingRegion fromJson(JsonObject jsonObject) {
75 String kind = jsonObject.get("kind").getAsString();
76 int offset = jsonObject.get("offset").getAsInt();
77 int length = jsonObject.get("length").getAsInt();
78 return new FoldingRegion(kind, offset, length);
79 }
80
81 public static List<FoldingRegion> fromJsonArray(JsonArray jsonArray) {
82 if (jsonArray == null) {
83 return EMPTY_LIST;
84 }
85 ArrayList<FoldingRegion> list = new ArrayList<FoldingRegion>(jsonArray.size());
86 Iterator<JsonElement> iterator = jsonArray.iterator();
87 while (iterator.hasNext()) {
88 list.add(fromJson(iterator.next().getAsJsonObject()));
89 }
90 return list;
91 }
92
93 /**
94 * The kind of the region.
95 */
96 public String getKind() {
97 return kind;
98 }
99
100 /**
101 * The length of the region to be folded.
102 */
103 public int getLength() {
104 return length;
105 }
106
107 /**
108 * The offset of the region to be folded.
109 */
110 public int getOffset() {
111 return offset;
112 }
113
114 @Override
115 public int hashCode() {
116 HashCodeBuilder builder = new HashCodeBuilder();
117 builder.append(kind);
118 builder.append(offset);
119 builder.append(length);
120 return builder.toHashCode();
121 }
122
123 public JsonObject toJson() {
124 JsonObject jsonObject = new JsonObject();
125 jsonObject.addProperty("kind", kind);
126 jsonObject.addProperty("offset", offset);
127 jsonObject.addProperty("length", length);
128 return jsonObject;
129 }
130
131 @Override
132 public String toString() {
133 StringBuilder builder = new StringBuilder();
134 builder.append("[");
135 builder.append("kind=");
136 builder.append(kind + ", ");
137 builder.append("offset=");
138 builder.append(offset + ", ");
139 builder.append("length=");
140 builder.append(length);
141 builder.append("]");
142 return builder.toString();
143 }
144
145}
static FoldingRegion fromJson(JsonObject jsonObject)
FoldingRegion(String kind, int offset, int length)
static List< FoldingRegion > fromJsonArray(JsonArray jsonArray)
size_t length
SeparatedVector2 offset