OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // This code was auto-generated, is not intended to be edited, and is subject to | |
6 // significant change. Please see the README file for more information. | |
7 | |
8 library engine.utilities.dart; | |
9 | |
10 import 'java_core.dart'; | |
11 | |
12 /** | |
13 * The enumeration `ParameterKind` defines the different kinds of parameters. Th
ere are two | |
14 * basic kinds of parameters: required and optional. Optional parameters are fur
ther divided into | |
15 * two kinds: positional optional and named optional. | |
16 */ | |
17 class ParameterKind extends Enum<ParameterKind> { | |
18 static const ParameterKind REQUIRED = | |
19 const ParameterKind('REQUIRED', 0, false); | |
20 | |
21 static const ParameterKind POSITIONAL = | |
22 const ParameterKind('POSITIONAL', 1, true); | |
23 | |
24 static const ParameterKind NAMED = const ParameterKind('NAMED', 2, true); | |
25 | |
26 static const List<ParameterKind> values = const [REQUIRED, POSITIONAL, NAMED]; | |
27 | |
28 /** | |
29 * A flag indicating whether this is an optional parameter. | |
30 */ | |
31 final bool isOptional; | |
32 | |
33 /** | |
34 * Initialize a newly created kind with the given state. | |
35 * | |
36 * @param isOptional `true` if this is an optional parameter | |
37 */ | |
38 const ParameterKind(String name, int ordinal, this.isOptional) | |
39 : super(name, ordinal); | |
40 } | |
41 | |
42 /** | |
43 * Check whether [uri1] starts with (or 'is prefixed by') [uri2] by checking | |
44 * path segments. | |
45 */ | |
46 bool startsWith(Uri uri1, Uri uri2) { | |
47 List<String> uri1Segments = uri1.pathSegments; | |
48 List<String> uri2Segments = uri2.pathSegments.toList(); | |
49 // Trim trailing empty segments ('/foo/' => ['foo', '']) | |
50 if (uri2Segments.last == '') { | |
51 uri2Segments.removeLast(); | |
52 } | |
53 | |
54 if (uri2Segments.length > uri1Segments.length) { | |
55 return false; | |
56 } | |
57 | |
58 for (int i = 0; i < uri2Segments.length; ++i) { | |
59 if (uri2Segments[i] != uri1Segments[i]) { | |
60 return false; | |
61 } | |
62 } | |
63 return true; | |
64 } | |
OLD | NEW |