Changeset View
Changeset View
Standalone View
Standalone View
src/main/java/net/wildfyre/api/Internal.java
/* | /* | ||||
Lint: Lint: :compileKotlin [01;31m[KFAILED[m[K | |||||
* Copyright 2018 Wildfyre.net | * Copyright 2018 Wildfyre.net | ||||
* | * | ||||
* Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
* you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | ||||
* You may obtain a copy of the License at | * You may obtain a copy of the License at | ||||
* | * | ||||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | ||||
Show All 36 Lines | public class Internal { | ||||
//region Cache content | //region Cache content | ||||
/** | /** | ||||
* Fully clears the cache, but keeps the token. | * Fully clears the cache, but keeps the token. | ||||
* @see #clean() Only remove the data that has expired | * @see #clean() Only remove the data that has expired | ||||
*/ | */ | ||||
public static void clear(){ | public static void clear(){ | ||||
Users.clear(); | Users.INSTANCE.clear(); | ||||
Areas.INSTANCE.clear(); | Areas.INSTANCE.clear(); | ||||
} | } | ||||
/** | /** | ||||
* Cleans the cache -- that is, removes every object that is not valid anymore from it (see | * Cleans the cache -- that is, removes every object that is not valid anymore from it (see | ||||
* {@link Descriptor#isValid()}). | * {@link Descriptor#isValid()}). | ||||
* @see #clear() Remove all data, not only the expired data | * @see #clear() Remove all data, not only the expired data | ||||
*/ | */ | ||||
public static void clean(){ | public static void clean(){ | ||||
Users.clean(); | Users.INSTANCE.clean(); | ||||
Areas.INSTANCE.clean(); | Areas.INSTANCE.clean(); | ||||
} | } | ||||
/** | /** | ||||
* Resets the API. | * Resets the API. | ||||
* <p>This means that the user's token is removed, and the cache is fully cleared.</p> | * <p>This means that the user's token is removed, and the cache is fully cleared.</p> | ||||
*/ | */ | ||||
public static void reset(){ | public static void reset(){ | ||||
clear(); | clear(); | ||||
token = null; | token = null; | ||||
Users.reset(); | Users.INSTANCE.reset(); | ||||
// No need to reset Areas, as they are already cleared by the Internal#clear() call above. | // No need to reset Areas, as they are already cleared by the Internal#clear() call above. | ||||
} | } | ||||
//endregion | //endregion | ||||
//region Getters | //region Getters | ||||
/** | /** | ||||
* Returns the token used for authentication. | * Returns the token used for authentication. | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | public class Internal { | ||||
/** | /** | ||||
* Connects to the server & tries to access the logged-user's ID. This is needed so the API can identify whether a | * Connects to the server & tries to access the logged-user's ID. This is needed so the API can identify whether a | ||||
* post is owned or not by the user. | * post is owned or not by the user. | ||||
* @throws Request.CantConnectException if the API cannot connect to the server | * @throws Request.CantConnectException if the API cannot connect to the server | ||||
*/ | */ | ||||
public static void init() throws Request.CantConnectException { | public static void init() throws Request.CantConnectException { | ||||
Internal.clear(); | Internal.clear(); | ||||
Users.init(); | Users.INSTANCE.init(); | ||||
Areas.INSTANCE.init(); | Areas.INSTANCE.init(); | ||||
} | } | ||||
//endregion | //endregion | ||||
} | } |
:compileKotlin [01;31m[KFAILED[m[K