Commit 776a20ba by Anton Sudak

Parametrize addBlockByKey in template helper

parent d99c2ef1
......@@ -95,8 +95,8 @@ public class Template {
* @param key
* @return the block
*/
public static AbstractBlock addBlockByKey(Class<? extends AbstractBlock> blockClass, String key) {
AbstractBlock newBlock = AbstractBlock.find.byKey(key);
public static <T extends AbstractBlock> T addBlockByKey(Class<T> blockClass, String key) {
T newBlock = (T) AbstractBlock.find.byKey(key);
if (newBlock == null) {
logger.info("Creating a new " + blockClass.getName() + " with key " + key);
......@@ -218,10 +218,10 @@ public class Template {
* Non-page-items have no visible flag thus are always considered visible.
*/
public static boolean isVisible(AbstractBlock block) {
if (block instanceof PageBlock) {
return ((PageBlock) block).isVisible();
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment