mirror of
https://github.com/Canner/WrenAI.git
synced 2026-09-01 04:57:29 +08:00
20b40643ba
* rename Accio to Wren * remove legacy description in readme * fix the example
69 lines
2.0 KiB
Java
69 lines
2.0 KiB
Java
/*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
package io.wren.cache;
|
|
|
|
import io.wren.base.WrenException;
|
|
import io.wren.base.dto.CacheInfo;
|
|
|
|
import java.util.Optional;
|
|
|
|
import static io.wren.base.metadata.StandardErrorCode.GENERIC_USER_ERROR;
|
|
import static java.util.Objects.requireNonNull;
|
|
|
|
public class CacheInfoPair
|
|
{
|
|
private final CacheInfo cacheInfo;
|
|
private final Optional<String> tableName;
|
|
private final Optional<String> errorMessage;
|
|
private final long createTime;
|
|
|
|
protected CacheInfoPair(CacheInfo cacheInfo, String tableName, long createTime)
|
|
{
|
|
this(cacheInfo, Optional.of(tableName), Optional.empty(), createTime);
|
|
}
|
|
|
|
protected CacheInfoPair(CacheInfo cacheInfo, Optional<String> tableName, Optional<String> errorMessage, long createTime)
|
|
{
|
|
this.cacheInfo = requireNonNull(cacheInfo, "cacheInfo is null");
|
|
this.tableName = requireNonNull(tableName, "tableName is null");
|
|
this.errorMessage = requireNonNull(errorMessage, "errorMessage is null");
|
|
this.createTime = createTime;
|
|
}
|
|
|
|
public CacheInfo getCacheInfo()
|
|
{
|
|
return cacheInfo;
|
|
}
|
|
|
|
public String getRequiredTableName()
|
|
{
|
|
return tableName.orElseThrow(() -> new WrenException(GENERIC_USER_ERROR, "Mapping table name is refreshing or not exists"));
|
|
}
|
|
|
|
public Optional<String> getTableName()
|
|
{
|
|
return tableName;
|
|
}
|
|
|
|
public Optional<String> getErrorMessage()
|
|
{
|
|
return errorMessage;
|
|
}
|
|
|
|
public long getCreateTime()
|
|
{
|
|
return createTime;
|
|
}
|
|
}
|