Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/DefaultSubscriptionInfo.java

Issue 29603697: Issue 5931 - Create tests for util package (Closed)
Patch Set: Created Nov. 10, 2017, 2:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package org.adblockplus.sbrowser.contentblocker.engine;
19
20 import android.support.annotation.NonNull;
21
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
25
26 public final class DefaultSubscriptionInfo implements Comparable<DefaultSubscrip tionInfo>
27 {
28 private final static String KEY_TITLE = "title";
29 private final static String KEY_URL = "url";
30 private final static String KEY_AUTHOR = "author";
31 private final static String KEY_PREFIXES = "prefixes";
32 private final static String KEY_SPECIALIZATION = "specialization";
33 private final static String KEY_HOMEPAGE = "homepage";
34 private final static String KEY_TYPE = "type";
35 private final static String KEY_COMPLETE = "complete";
36
37 DefaultSubscriptionInfo parent = null;
38 final List<DefaultSubscriptionInfo> variants = new ArrayList<>();
39 final List<DefaultSubscriptionInfo> supplements = new ArrayList<>();
40 final HashMap<String, String> attributes = new HashMap<>();
41
42 private String getValue(final String key)
43 {
44 final String value = this.attributes.get(key);
45 return value != null ? value : "";
46 }
47
48 public String getTitle()
49 {
50 return this.getValue(KEY_TITLE);
51 }
52
53 public String getUrl()
54 {
55 return this.getValue(KEY_URL);
56 }
57
58 public String getHomepage()
59 {
60 return this.getValue(KEY_HOMEPAGE);
61 }
62
63 public String getAuthor()
64 {
65 return this.getValue(KEY_AUTHOR);
66 }
67
68 public String getPrefixes()
69 {
70 return this.getValue(KEY_PREFIXES);
71 }
72
73 public String getSpecialization()
74 {
75 return this.getValue(KEY_SPECIALIZATION);
76 }
77
78 public String getType()
79 {
80 return this.getValue(KEY_TYPE);
81 }
82
83 public boolean isComplete()
84 {
85 return this.getValue(KEY_COMPLETE).equals("true");
86 }
87
88 @Override
89 public int compareTo(@NonNull final DefaultSubscriptionInfo o)
90 {
91 final int cmp = this.getTitle().compareTo(o.getTitle());
92 if (cmp != 0)
93 {
94 return cmp;
95 }
96 return this.getUrl().compareTo(o.getUrl());
97 }
98
99 @Override
100 public String toString()
101 {
102 return this.getTitle() + ": " + this.getUrl();
103 }
104 }
OLDNEW

Powered by Google App Engine
This is Rietveld