blob: a4787a16ca51f73030145ae215d4746d55ebc02a [file] [log] [blame]
Simon Hunt6c2555b2015-05-21 18:17:56 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.onosproject.cord.gui.model;
19
20import com.fasterxml.jackson.databind.node.ObjectNode;
21
22/**
23 * Specialization of XosFunction for URL filtering.
24 */
25public class UrlFilterFunction extends DefaultXosFunction {
26
27 private static final String LEVEL = "level";
28
29 /**
30 * Denotes the URL filtering levels available.
31 */
32 public enum Level { PG, PG_13, R }
33
34 /**
35 * The default URL filtering level
36 */
37 public static final Level DEFAULT_LEVEL = Level.PG;
38
39 public UrlFilterFunction(XosFunctionDescriptor xfd) {
40 super(xfd);
41 }
42
43 @Override
44 public Memento createMemento() {
45 return new UrlFilterMemento();
46 }
47
48 class UrlFilterMemento implements Memento {
49 private Level level = DEFAULT_LEVEL;
50
51 public ObjectNode toObjectNode() {
52 ObjectNode node = MAPPER.createObjectNode();
53 node.put(LEVEL, level.name());
54 return node;
55 }
56
57 public void setLevel(Level level) {
58 this.level = level;
59 }
60 }
61}