BrightSide Workbench Full Report + Source Code
SessionGoals.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.web.funnel;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletResponse;
25 import org.turro.elephant.context.AbstractSessionObject;
26 import org.turro.elephant.context.IConstructor;
27 
32 public class SessionGoals extends AbstractSessionObject<SessionGoals> {
33 
34  public List<String> goals() {
35  return goals;
36  }
37 
38  public List<String> goals(List<String> newGoals) {
39  goals.clear();
40  goals.addAll(newGoals);
41  return goals;
42  }
43 
44  /* Factory */
45 
46  public static String key() {
47  return "web-goals";
48  }
49 
50  public static SessionGoals get() {
51  return AbstractSessionObject.get(key(), () -> new SessionGoals());
52  }
53 
54  public static SessionGoals get(HttpServletRequest request, HttpServletResponse response) {
55  return AbstractSessionObject.get(request, response, key(), () -> new SessionGoals());
56  }
57 
58  public static SessionGoals get(IConstructor constructor) {
59  return AbstractSessionObject.get(constructor, key(), () -> new SessionGoals());
60  }
61 
62  public static void remove() {
64  }
65 
66  public static void remove(HttpServletRequest request, HttpServletResponse response) {
67  AbstractSessionObject.remove(request, response, key());
68  }
69 
70  public static void remove(IConstructor constructor) {
71  AbstractSessionObject.remove(constructor, key());
72  }
73 
74  private final List<String> goals;
75 
76  private SessionGoals() {
77  this.goals = new ArrayList<>();
78  }
79 
80 }
static< E > E get(String key, Supplier< E > supplier)
List< String > goals(List< String > newGoals)