<commit_before>package org.orienteer.pages;

import org.apache.wicket.core.request.handler.IPageClassRequestHandler;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.mapper.parameter.PageParametersEncoder;
import org.apache.wicket.util.string.StringValue;

import com.orientechnologies.orient.core.id.ORID;

/**
 * {@link IPageParametersEncoder} for transparent adding page Id
 */
public class OPageParametersEncoder extends PageParametersEncoder {

	public static final String PAGE_IDENTITY = "__orienteerPageId__";
	
	private final ORID pageIdentity;
	
	public OPageParametersEncoder(ORID pageIdentity) {
		this.pageIdentity = pageIdentity;
	}
	@Override
	public PageParameters decodePageParameters(Url url) {
		PageParameters ret =  super.decodePageParameters(url);
		if(ret==null) ret = new PageParameters();
		ret.add(PAGE_IDENTITY, pageIdentity);
		return ret;
	}

	@Override
	public Url encodePageParameters(PageParameters pageParameters) {
		StringValue sv = pageParameters.get(PAGE_IDENTITY);
		if(!sv.isEmpty()) {
			pageParameters.remove(PAGE_IDENTITY);
		}
		Url ret = super.encodePageParameters(pageParameters);
		if(!sv.isEmpty()) {
			pageParameters.add(PAGE_IDENTITY, sv.toString());
		}
		return ret;
	}
	
	public static boolean matchHandler(ORID pageIdentity, IPageClassRequestHandler requestHandler) {
		StringValue sv = requestHandler.getPageParameters().get(PAGE_IDENTITY);
		return pageIdentity!=null?pageIdentity.toString().equals(sv.toOptionalString()):false;
	}
	
}<commit_msg>Fix NPE in OPages<commit_after>package org.orienteer.pages;

import org.apache.wicket.core.request.handler.IPageClassRequestHandler;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.mapper.parameter.PageParametersEncoder;
import org.apache.wicket.util.string.StringValue;

import com.orientechnologies.orient.core.id.ORID;

/**
 * {@link IPageParametersEncoder} for transparent adding page Id
 */
public class OPageParametersEncoder extends PageParametersEncoder {

	public static final String PAGE_IDENTITY = "__orienteerPageId__";
	
	private final ORID pageIdentity;
	
	public OPageParametersEncoder(ORID pageIdentity) {
		this.pageIdentity = pageIdentity;
	}
	@Override
	public PageParameters decodePageParameters(Url url) {
		PageParameters ret =  super.decodePageParameters(url);
		if(ret==null) ret = new PageParameters();
		ret.add(PAGE_IDENTITY, pageIdentity);
		return ret;
	}

	@Override
	public Url encodePageParameters(PageParameters pageParameters) {
		StringValue sv = pageParameters.get(PAGE_IDENTITY);
		if(!sv.isEmpty()) {
			pageParameters.remove(PAGE_IDENTITY);
		}
		Url ret = super.encodePageParameters(pageParameters);
		if(!sv.isEmpty()) {
			pageParameters.add(PAGE_IDENTITY, sv.toString());
		}
		return ret;
	}
	
	public static boolean matchHandler(ORID pageIdentity, IPageClassRequestHandler requestHandler) {
		PageParameters params = requestHandler.getPageParameters();
		StringValue sv = params!=null?params.get(PAGE_IDENTITY):null;
		return sv!=null && pageIdentity!=null?pageIdentity.toString().equals(sv.toOptionalString()):false;
	}
	
}
{'fraction_non_alphanumeric': 0.10247349823321555, 'fraction_numerical': 0.0, 'mean_word_length': 6.166666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7252561', 'n_tokens_mistral': 1043, 'n_tokens_neox': 984, 'n_words': 185}